file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Vale.AES.GCM.fst | Vale.AES.GCM.gcm_blocks_dec_helper_simplified | val gcm_blocks_dec_helper_simplified (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures(let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
le_quad32_to_bytes enc_hash == gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes)) | val gcm_blocks_dec_helper_simplified (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures(let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
le_quad32_to_bytes enc_hash == gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes)) | let gcm_blocks_dec_helper_simplified (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures(let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
le_quad32_to_bytes enc_hash == gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes))
=
gcm_blocks_dec_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes a_num_bytes iv j0_BE h enc_hash length_quad;
let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher_raw_quads:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes;
lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes;
lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes;
() | {
"file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 1145,
"start_col": 0,
"start_line": 1050
} | module Vale.AES.GCM
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.GCM_s
open Vale.AES.AES_s
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GHash_s
open FStar.Mul
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Calc
open Vale.Def.Words.Four_s
let lemma_set_to_one_equality (q0 q1:quad32) : Lemma
(requires upper3_equal q0 q1)
(ensures set_to_one_LE q0 == set_to_one_LE q1)
=
()
let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma
(requires lower3_equal q0 q1)
(ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1))
=
reveal_reverse_bytes_quad32 q0;
reveal_reverse_bytes_quad32 q1;
()
let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma
(requires slice b0 0 12 == slice b1 0 12)
(ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1))
=
let q0 = le_bytes_to_quad32 b0 in
let q1 = le_bytes_to_quad32 b1 in
le_bytes_to_quad32_reveal ();
(*
* AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this?
*)
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\
index b1 i == index (slice b1 0 12) i))
let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma
(slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
=
assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
(slice (le_quad32_to_bytes q) 0 12));
()
let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma
(requires
length iv_extra_b == 1 /\
length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\
num_bytes == 96/8 /\
(let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in
j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\
(let raw_quads = append iv_b iv_extra_b in
let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in
iv_bytes == iv))
(ensures j0 == compute_iv_BE h_LE iv)
=
assert (length iv == 12);
assert (length iv_b == 0);
lemma_empty iv_b;
append_empty_l iv_extra_b;
assert (append iv_b iv_extra_b == iv_extra_b);
let q = index iv_extra_b 0 in
le_seq_quad32_to_bytes_of_singleton q;
assert (equal iv_extra_b (create 1 q));
assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q);
// Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below
calc (==) {
slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12;
== {}
slice (pad_to_128_bits iv) 0 12;
};
// Prove this so we can call lemma_set_to_one_reverse_equality below
calc (==) {
le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits iv);
};
calc (==) {
j0;
== {}
set_to_one_LE (reverse_bytes_quad32 q);
== { le_bytes_to_quad32_to_bytes q }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q)));
== {
lemma_le_seq_quad32_to_bytes_prefix_equality q;
lemma_le_bytes_to_quad32_prefix_equality
(le_quad32_to_bytes q)
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12));
lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (le_quad32_to_bytes q))
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
}
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))));
== { lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
(le_bytes_to_quad32 (pad_to_128_bits iv));
lemma_le_bytes_to_quad32_prefix_equality
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))
(pad_to_128_bits iv) }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv)));
== {compute_iv_BE_reveal ()}
compute_iv_BE h_LE iv;
};
()
open Vale.AES.GHash
let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma
(requires
~(length iv == 96/8) /\
quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\
j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\
length_quad == reverse_bytes_quad32 (insert_nat64
(insert_nat64
(Mkfour 0 0 0 0) 0 1)
(8 * (length iv)) 0))
(ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv)
=
assert (two_to_nat32 (Mktwo 0 0) == 0);
let q0 = Mkfour 0 0 0 0 in
lemma_insert_nat64_nat32s q0 0 0;
assert (insert_nat64 q0 0 1 == q0);
insert_nat64_reveal ();
assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0));
ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad));
compute_iv_BE_reveal ();
()
let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\
cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\
length plain < pow2_32 /\
length auth < pow2_32
))
(ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
=
gcm_encrypt_LE_reveal ()
(*
let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in
let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in
let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in
let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in
be_bytes_to_quad32_to_bytes iv_BE;
assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE);
assert (s_iv_BE == iv_BE);
assert (s_key_LE == key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE ==
gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key ==
gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key ==
gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key);
()
*)
let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv /\
length plain < pow2_32 /\
length auth < pow2_32 /\
cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\
length_quad32 == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\
(let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\
le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key)
))
(ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
=
insert_nat64_reveal ();
gcm_encrypt_LE_reveal ()
//be_bytes_to_quad32_to_bytes iv_BE;
//let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in
//()
#reset-options "--z3rlimit 10"
let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32)
(p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(auth_bytes:seq nat8)
(p_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
(length auth_bytes) < pow2_32 /\
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\
(let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2
)))
(ensures (let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
//cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key))
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)))
=
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
gctr_partial_opaque_completed alg plain cipher key ctr_BE_2;
if p_num_bytes > (length p128x6 + length p128) * 16 then (
gctr_partial_reveal ();
assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2);
assert (equal (slice plain 0 (length p128x6 + length p128))
(slice (append p128x6 p128) 0 (length p128x6 + length p128)));
assert (equal (slice cipher 0 (length p128x6 + length p128))
(slice (append c128x6 c128) 0 (length p128x6 + length p128)));
gctr_partial_opaque_ignores_postfix
alg (length p128x6 + length p128)
plain (append p128x6 p128)
cipher (append c128x6 c128)
key ctr_BE_2;
assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2);
gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2;
let num_blocks = p_num_bytes / 16 in
assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks)));
gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks;
assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks ==
gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0);
aes_encrypt_LE_reveal ();
gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes;
assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)
) else (
gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher;
assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key);
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
assert (equal plain_bytes (le_seq_quad32_to_bytes plain));
assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher));
assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)
);
gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key;
()
let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma
(requires length x <= i /\ i <= length x + length y)
(ensures slice (append x y) 0 i == append x (slice y 0 (i - length x)))
=
assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x))));
()
let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) :
Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y))
=
append_distributes_le_seq_quad32_to_bytes x y
let pad_to_128_bits_multiple_append (x y:seq nat8) : Lemma
(requires length x % 16 == 0)
(ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y))
=
assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y)))
#reset-options "--z3rlimit 100"
let gcm_blocks_helper (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes)))
=
let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
let hash = ghash_LE h final_quads in
gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes iv j0_BE;
//assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain_bytes auth_input_bytes)); // Passes
calc (==) {
enc_hash;
== {}
gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0;
== {}
gctr_encrypt_block ctr_BE_1 hash alg key 0;
== {}
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== { aes_encrypt_LE_reveal () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== {}
quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1);
};
calc (==) {
gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key;
== { gctr_encrypt_one_block ctr_BE_1 hash alg key }
le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1)));
== {}
le_seq_quad32_to_bytes (create 1 enc_hash);
== { le_seq_quad32_to_bytes_of_singleton enc_hash }
le_quad32_to_bytes enc_hash;
};
if p_num_bytes > (length p128x6 + length p128) * 16 then (
let c = append (append c128x6 c128) c_bytes in
calc (==) {
append (append (append auth_quads c128x6) c128) c_bytes;
== { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) c_bytes;
== { append_assoc auth_quads (append c128x6 c128) c_bytes }
append auth_quads (append (append c128x6 c128) c_bytes);
== {}
append auth_quads c;
};
calc (==) {
append (append (append (append auth_quads c128x6) c128) c_bytes) (create 1 length_quad);
= {} // See previous calc
append (append auth_quads (append (append c128x6 c128) c_bytes)) (create 1 length_quad);
== { append_assoc auth_quads c (create 1 length_quad) }
append auth_quads (append c (create 1 length_quad));
};
let raw_quads_old = append auth_quads c in
calc (==) {
raw_quads;
== {}
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes));
== {
calc (==) {
pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes);
== {
calc (==) {
slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes;
== { append_distributes_le_seq_quad32_to_bytes auth_quads c }
slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes;
== { slice_append_back (le_seq_quad32_to_bytes auth_quads)
(le_seq_quad32_to_bytes c)
total_bytes }
append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes);
== {}
append (le_seq_quad32_to_bytes auth_quads) cipher_bytes;
}
}
pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) cipher_bytes);
== { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) cipher_bytes }
append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes);
}
}
le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes));
== { append_distributes_le_bytes_to_seq_quad32
(le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits cipher_bytes) }
append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
== { le_bytes_to_seq_quad32_to_bytes auth_quads }
append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
};
let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in
let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes) in
calc (==) {
append raw_quads (create 1 length_quad);
== {}
append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes))) (create 1 length_quad);
== { assert (equal auth_quads auth_padded_quads') }
append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad);
== { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) }
append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad));
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key;
()
) else (
calc (==) {
append (append (append auth_quads c128x6) c128) (create 1 length_quad);
== { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) (create 1 length_quad);
== { append_assoc auth_quads (append c128x6 c128) (create 1 length_quad) }
append auth_quads (append (append c128x6 c128) (create 1 length_quad));
};
let c = append c128x6 c128 in
calc (==) {
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes));
== { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) }
le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c));
== { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) }
le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c);
== { le_bytes_to_seq_quad32_to_bytes c }
c;
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key;
()
);
()
// TODO: remove duplicate code -- there is an identical copy of this in GCTR.fst
let lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma
(requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\
(num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\
length s * 16 <= num_bytes /\
num_bytes < length s * 16 + 16 /\
length bytes == 1
)
(ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes ==
slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes)
=
if num_bytes > (length s) * 16 then (
()
) else (
calc (==) {
slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes;
== { append_distributes_le_seq_quad32_to_bytes s bytes }
slice (append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes)) 0 num_bytes;
== { Vale.Lib.Seqs.lemma_slice_first_exactly_in_append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes) }
le_seq_quad32_to_bytes s;
== { assert (length (le_seq_quad32_to_bytes s) == num_bytes) }
slice (le_seq_quad32_to_bytes s) 0 num_bytes;
};
()
)
#reset-options "--z3rlimit 10"
let gcm_blocks_helper_simplified (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes))
)
=
gcm_blocks_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes a_num_bytes iv j0_BE h enc_hash length_quad;
let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher_raw_quads:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes;
lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes;
lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes;
()
let lemma_gcm_encrypt_decrypt_equiv (alg:algorithm) (key:seq nat32) (iv:supported_iv_LE) (j0_BE:quad32) (plain cipher auth alleged_tag:seq nat8) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv) /\
length cipher < pow2_32 /\
length auth < pow2_32 /\
plain == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth)
)
(ensures plain == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth alleged_tag))
=
gcm_encrypt_LE_reveal ();
gcm_decrypt_LE_reveal ();
()
let gcm_blocks_helper_dec_simplified (alg:algorithm) (key:seq nat32)
(p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(auth_bytes alleged_tag:seq nat8)
(p_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
(length auth_bytes) < pow2_32 /\
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\
(let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2
))
(ensures (let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes alleged_tag)))
=
gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_bytes p_num_bytes iv j0_BE;
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher_raw_quads:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes;
lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes;
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes));
lemma_gcm_encrypt_decrypt_equiv alg key iv j0_BE cipher_bytes plain_bytes auth_bytes alleged_tag;
()
#reset-options "--z3rlimit 60"
let gcm_blocks_dec_helper (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
le_quad32_to_bytes enc_hash == gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes))
=
insert_nat64_reveal ();
let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
let hash = ghash_LE h final_quads in
//gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes j0_BE;
//assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes j0_BE) plain_bytes auth_input_bytes)); // Passes
calc (==) {
enc_hash;
== {}
gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0;
== {}
gctr_encrypt_block ctr_BE_1 hash alg key 0;
== {}
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== { aes_encrypt_LE_reveal () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== {}
quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1);
};
calc (==) {
gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key;
== { gctr_encrypt_one_block ctr_BE_1 hash alg key }
le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1)));
== {}
le_seq_quad32_to_bytes (create 1 enc_hash);
== { le_seq_quad32_to_bytes_of_singleton enc_hash }
le_quad32_to_bytes enc_hash;
};
if p_num_bytes > (length p128x6 + length p128) * 16 then (
let c = append (append p128x6 p128) p_bytes in
calc (==) {
append (append (append auth_quads p128x6) p128) p_bytes;
== { append_assoc auth_quads p128x6 p128 }
append (append auth_quads (append p128x6 p128)) p_bytes;
== { append_assoc auth_quads (append p128x6 p128) p_bytes }
append auth_quads (append (append p128x6 p128) p_bytes);
== {}
append auth_quads c;
};
calc (==) {
append (append (append (append auth_quads p128x6) p128) p_bytes) (create 1 length_quad);
= {} // See previous calc
append (append auth_quads (append (append p128x6 p128) p_bytes)) (create 1 length_quad);
== { append_assoc auth_quads c (create 1 length_quad) }
append auth_quads (append c (create 1 length_quad));
};
let raw_quads_old = append auth_quads c in
calc (==) {
raw_quads;
== {}
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes));
== {
calc (==) {
pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes);
== {
calc (==) {
slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes;
== { append_distributes_le_seq_quad32_to_bytes auth_quads c }
slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes;
== { slice_append_back (le_seq_quad32_to_bytes auth_quads)
(le_seq_quad32_to_bytes c)
total_bytes }
append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes);
== { assert(equal (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes) plain_bytes) }
append (le_seq_quad32_to_bytes auth_quads) plain_bytes;
}
}
pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) plain_bytes);
== { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) plain_bytes }
append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits plain_bytes);
}
}
le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits plain_bytes));
== { append_distributes_le_bytes_to_seq_quad32
(le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits plain_bytes) }
append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes));
== { le_bytes_to_seq_quad32_to_bytes auth_quads }
append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes));
};
let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in
let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes) in
calc (==) {
append raw_quads (create 1 length_quad);
== {}
append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes))) (create 1 length_quad);
== { assert (equal auth_quads auth_padded_quads') }
append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad);
== { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) }
append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad));
};
()
) else (
calc (==) {
append (append (append auth_quads p128x6) p128) (create 1 length_quad);
== { append_assoc auth_quads p128x6 p128 }
append (append auth_quads (append p128x6 p128)) (create 1 length_quad);
== { append_assoc auth_quads (append p128x6 p128) (create 1 length_quad) }
append auth_quads (append (append p128x6 p128) (create 1 length_quad));
};
let c = append p128x6 p128 in
calc (==) {
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes));
== { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) }
le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c));
== { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) }
le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c);
== { le_bytes_to_seq_quad32_to_bytes c }
c;
};
()
);
() | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.GCM.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 ->
a128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
a_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p_num_bytes: Prims.nat ->
a_num_bytes: Prims.nat ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
j0_BE: Vale.Def.Types_s.quad32 ->
h: Vale.Def.Types_s.quad32 ->
enc_hash: Vale.Def.Types_s.quad32 ->
length_quad: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 <= p_num_bytes /\
p_num_bytes < FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 + 16 /\
FStar.Seq.Base.length a128 * 16 <= a_num_bytes /\
a_num_bytes < FStar.Seq.Base.length a128 * 16 + 16 /\ a_num_bytes < Vale.Def.Words_s.pow2_32 /\
FStar.Seq.Base.length p128x6 == FStar.Seq.Base.length c128x6 /\
FStar.Seq.Base.length p128 == FStar.Seq.Base.length c128 /\
FStar.Seq.Base.length p_bytes == 1 /\ FStar.Seq.Base.length c_bytes == 1 /\
FStar.Seq.Base.length a_bytes == 1 /\ Vale.AES.AES_s.is_aes_key_LE alg key /\
j0_BE == Vale.AES.GCM_s.compute_iv_BE h iv /\
h = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour 0 0 0 0) /\
p_num_bytes < Vale.Def.Words_s.pow2_32 /\ a_num_bytes < Vale.Def.Words_s.pow2_32 /\
length_quad ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Words_s.Mkfour 0 0 0 0)
(8 * a_num_bytes)
1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1 = j0_BE in
let ctr_BE_2 = Vale.AES.GCTR_s.inc32 j0_BE 1 in
let plain =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes
| _ -> FStar.Seq.Base.append p128x6 p128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes
| _ -> FStar.Seq.Base.append c128x6 c128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher_bound =
FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128 +
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> 1
| _ -> 0)
in
Vale.AES.GCTR.gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
(match a_num_bytes > FStar.Seq.Base.length a128 * 16 with
| true -> FStar.Seq.Base.append a128 a_bytes
| _ -> a128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let auth_input_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
a_num_bytes
in
let auth_padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in
let auth_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = FStar.Seq.Base.append (FStar.Seq.Base.append auth_quads p128x6) p128 in
let total_bytes = FStar.Seq.Base.length auth_quads * 16 + p_num_bytes in
let raw_quads =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true ->
let raw_quads = FStar.Seq.Base.append raw_quads p_bytes in
let input_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads)
0
total_bytes
in
let input_padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in
Vale.Def.Types_s.le_bytes_to_seq_quad32 input_padded_bytes
| _ -> raw_quads)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let final_quads =
FStar.Seq.Base.append raw_quads (FStar.Seq.Base.create 1 length_quad)
in
enc_hash ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1
(Vale.AES.GHash_s.ghash_LE h final_quads)
alg
key
0)))
(ensures
(let auth_raw_quads = FStar.Seq.Base.append a128 a_bytes in
let auth_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
a_num_bytes
in
let plain_raw_quads = FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes in
let plain_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads)
0
p_num_bytes
in
let cipher_raw_quads =
FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes
in
let cipher_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads)
0
p_num_bytes
in
FStar.Seq.Base.length auth_bytes < Vale.Def.Words_s.pow2_32 /\
FStar.Seq.Base.length plain_bytes < Vale.Def.Words_s.pow2_32 /\
Vale.Def.Types_s.le_quad32_to_bytes enc_hash ==
Vale.AES.GCM.gcm_decrypt_LE_tag alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
plain_bytes
auth_bytes)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat32",
"Vale.Def.Types_s.quad32",
"Prims.nat",
"Vale.AES.GCM_s.supported_iv_LE",
"Prims.unit",
"Vale.AES.GCM.lemma_length_simplifier",
"FStar.Seq.Base.append",
"Prims.op_GreaterThan",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Prims.bool",
"Vale.AES.GCM.gcm_blocks_dec_helper",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_32",
"Prims.eq2",
"Prims.int",
"Vale.AES.AES_s.is_aes_key_LE",
"Vale.AES.GCM_s.compute_iv_BE",
"Prims.op_Equality",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.Def.Types_s.insert_nat64",
"Vale.AES.GCTR.gctr_partial",
"Vale.AES.GCTR_s.gctr_encrypt_block",
"Vale.AES.GHash_s.ghash_LE",
"FStar.Seq.Base.create",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.Def.Words_s.nat8",
"Vale.AES.GCTR_s.pad_to_128_bits",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.AES.GCTR_s.inc32",
"Prims.squash",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.AES.GCM.gcm_decrypt_LE_tag",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let gcm_blocks_dec_helper_simplified
(alg: algorithm)
(key: seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32)
(p_num_bytes a_num_bytes: nat)
(iv: supported_iv_LE)
(j0_BE h enc_hash length_quad: quad32)
: Lemma
(requires
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\
length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad ==
reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0)))
(ensures
(let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\
le_quad32_to_bytes enc_hash ==
gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)) =
| gcm_blocks_dec_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes
a_num_bytes iv j0_BE h enc_hash length_quad;
let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher_raw_quads:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes;
lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes;
lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes;
() | false |
Vale.AES.GCM.fst | Vale.AES.GCM.gcm_blocks_helper_simplified | val gcm_blocks_helper_simplified (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes))
) | val gcm_blocks_helper_simplified (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes))
) | let gcm_blocks_helper_simplified (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes))
)
=
gcm_blocks_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes a_num_bytes iv j0_BE h enc_hash length_quad;
let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher_raw_quads:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes;
lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes;
lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes;
() | {
"file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 712,
"start_col": 0,
"start_line": 614
} | module Vale.AES.GCM
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.GCM_s
open Vale.AES.AES_s
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GHash_s
open FStar.Mul
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Calc
open Vale.Def.Words.Four_s
let lemma_set_to_one_equality (q0 q1:quad32) : Lemma
(requires upper3_equal q0 q1)
(ensures set_to_one_LE q0 == set_to_one_LE q1)
=
()
let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma
(requires lower3_equal q0 q1)
(ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1))
=
reveal_reverse_bytes_quad32 q0;
reveal_reverse_bytes_quad32 q1;
()
let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma
(requires slice b0 0 12 == slice b1 0 12)
(ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1))
=
let q0 = le_bytes_to_quad32 b0 in
let q1 = le_bytes_to_quad32 b1 in
le_bytes_to_quad32_reveal ();
(*
* AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this?
*)
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\
index b1 i == index (slice b1 0 12) i))
let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma
(slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
=
assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
(slice (le_quad32_to_bytes q) 0 12));
()
let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma
(requires
length iv_extra_b == 1 /\
length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\
num_bytes == 96/8 /\
(let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in
j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\
(let raw_quads = append iv_b iv_extra_b in
let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in
iv_bytes == iv))
(ensures j0 == compute_iv_BE h_LE iv)
=
assert (length iv == 12);
assert (length iv_b == 0);
lemma_empty iv_b;
append_empty_l iv_extra_b;
assert (append iv_b iv_extra_b == iv_extra_b);
let q = index iv_extra_b 0 in
le_seq_quad32_to_bytes_of_singleton q;
assert (equal iv_extra_b (create 1 q));
assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q);
// Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below
calc (==) {
slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12;
== {}
slice (pad_to_128_bits iv) 0 12;
};
// Prove this so we can call lemma_set_to_one_reverse_equality below
calc (==) {
le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits iv);
};
calc (==) {
j0;
== {}
set_to_one_LE (reverse_bytes_quad32 q);
== { le_bytes_to_quad32_to_bytes q }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q)));
== {
lemma_le_seq_quad32_to_bytes_prefix_equality q;
lemma_le_bytes_to_quad32_prefix_equality
(le_quad32_to_bytes q)
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12));
lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (le_quad32_to_bytes q))
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
}
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))));
== { lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
(le_bytes_to_quad32 (pad_to_128_bits iv));
lemma_le_bytes_to_quad32_prefix_equality
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))
(pad_to_128_bits iv) }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv)));
== {compute_iv_BE_reveal ()}
compute_iv_BE h_LE iv;
};
()
open Vale.AES.GHash
let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma
(requires
~(length iv == 96/8) /\
quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\
j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\
length_quad == reverse_bytes_quad32 (insert_nat64
(insert_nat64
(Mkfour 0 0 0 0) 0 1)
(8 * (length iv)) 0))
(ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv)
=
assert (two_to_nat32 (Mktwo 0 0) == 0);
let q0 = Mkfour 0 0 0 0 in
lemma_insert_nat64_nat32s q0 0 0;
assert (insert_nat64 q0 0 1 == q0);
insert_nat64_reveal ();
assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0));
ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad));
compute_iv_BE_reveal ();
()
let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\
cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\
length plain < pow2_32 /\
length auth < pow2_32
))
(ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
=
gcm_encrypt_LE_reveal ()
(*
let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in
let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in
let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in
let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in
be_bytes_to_quad32_to_bytes iv_BE;
assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE);
assert (s_iv_BE == iv_BE);
assert (s_key_LE == key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE ==
gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key ==
gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key ==
gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key);
()
*)
let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv /\
length plain < pow2_32 /\
length auth < pow2_32 /\
cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\
length_quad32 == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\
(let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\
le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key)
))
(ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
=
insert_nat64_reveal ();
gcm_encrypt_LE_reveal ()
//be_bytes_to_quad32_to_bytes iv_BE;
//let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in
//()
#reset-options "--z3rlimit 10"
let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32)
(p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(auth_bytes:seq nat8)
(p_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
(length auth_bytes) < pow2_32 /\
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\
(let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2
)))
(ensures (let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
//cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key))
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)))
=
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
gctr_partial_opaque_completed alg plain cipher key ctr_BE_2;
if p_num_bytes > (length p128x6 + length p128) * 16 then (
gctr_partial_reveal ();
assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2);
assert (equal (slice plain 0 (length p128x6 + length p128))
(slice (append p128x6 p128) 0 (length p128x6 + length p128)));
assert (equal (slice cipher 0 (length p128x6 + length p128))
(slice (append c128x6 c128) 0 (length p128x6 + length p128)));
gctr_partial_opaque_ignores_postfix
alg (length p128x6 + length p128)
plain (append p128x6 p128)
cipher (append c128x6 c128)
key ctr_BE_2;
assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2);
gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2;
let num_blocks = p_num_bytes / 16 in
assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks)));
gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks;
assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks ==
gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0);
aes_encrypt_LE_reveal ();
gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes;
assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)
) else (
gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher;
assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key);
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
assert (equal plain_bytes (le_seq_quad32_to_bytes plain));
assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher));
assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)
);
gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key;
()
let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma
(requires length x <= i /\ i <= length x + length y)
(ensures slice (append x y) 0 i == append x (slice y 0 (i - length x)))
=
assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x))));
()
let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) :
Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y))
=
append_distributes_le_seq_quad32_to_bytes x y
let pad_to_128_bits_multiple_append (x y:seq nat8) : Lemma
(requires length x % 16 == 0)
(ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y))
=
assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y)))
#reset-options "--z3rlimit 100"
let gcm_blocks_helper (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes)))
=
let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
let hash = ghash_LE h final_quads in
gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes iv j0_BE;
//assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain_bytes auth_input_bytes)); // Passes
calc (==) {
enc_hash;
== {}
gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0;
== {}
gctr_encrypt_block ctr_BE_1 hash alg key 0;
== {}
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== { aes_encrypt_LE_reveal () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== {}
quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1);
};
calc (==) {
gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key;
== { gctr_encrypt_one_block ctr_BE_1 hash alg key }
le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1)));
== {}
le_seq_quad32_to_bytes (create 1 enc_hash);
== { le_seq_quad32_to_bytes_of_singleton enc_hash }
le_quad32_to_bytes enc_hash;
};
if p_num_bytes > (length p128x6 + length p128) * 16 then (
let c = append (append c128x6 c128) c_bytes in
calc (==) {
append (append (append auth_quads c128x6) c128) c_bytes;
== { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) c_bytes;
== { append_assoc auth_quads (append c128x6 c128) c_bytes }
append auth_quads (append (append c128x6 c128) c_bytes);
== {}
append auth_quads c;
};
calc (==) {
append (append (append (append auth_quads c128x6) c128) c_bytes) (create 1 length_quad);
= {} // See previous calc
append (append auth_quads (append (append c128x6 c128) c_bytes)) (create 1 length_quad);
== { append_assoc auth_quads c (create 1 length_quad) }
append auth_quads (append c (create 1 length_quad));
};
let raw_quads_old = append auth_quads c in
calc (==) {
raw_quads;
== {}
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes));
== {
calc (==) {
pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes);
== {
calc (==) {
slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes;
== { append_distributes_le_seq_quad32_to_bytes auth_quads c }
slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes;
== { slice_append_back (le_seq_quad32_to_bytes auth_quads)
(le_seq_quad32_to_bytes c)
total_bytes }
append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes);
== {}
append (le_seq_quad32_to_bytes auth_quads) cipher_bytes;
}
}
pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) cipher_bytes);
== { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) cipher_bytes }
append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes);
}
}
le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes));
== { append_distributes_le_bytes_to_seq_quad32
(le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits cipher_bytes) }
append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
== { le_bytes_to_seq_quad32_to_bytes auth_quads }
append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
};
let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in
let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes) in
calc (==) {
append raw_quads (create 1 length_quad);
== {}
append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes))) (create 1 length_quad);
== { assert (equal auth_quads auth_padded_quads') }
append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad);
== { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) }
append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad));
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key;
()
) else (
calc (==) {
append (append (append auth_quads c128x6) c128) (create 1 length_quad);
== { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) (create 1 length_quad);
== { append_assoc auth_quads (append c128x6 c128) (create 1 length_quad) }
append auth_quads (append (append c128x6 c128) (create 1 length_quad));
};
let c = append c128x6 c128 in
calc (==) {
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes));
== { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) }
le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c));
== { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) }
le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c);
== { le_bytes_to_seq_quad32_to_bytes c }
c;
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key;
()
);
()
// TODO: remove duplicate code -- there is an identical copy of this in GCTR.fst
let lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma
(requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\
(num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\
length s * 16 <= num_bytes /\
num_bytes < length s * 16 + 16 /\
length bytes == 1
)
(ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes ==
slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes)
=
if num_bytes > (length s) * 16 then (
()
) else (
calc (==) {
slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes;
== { append_distributes_le_seq_quad32_to_bytes s bytes }
slice (append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes)) 0 num_bytes;
== { Vale.Lib.Seqs.lemma_slice_first_exactly_in_append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes) }
le_seq_quad32_to_bytes s;
== { assert (length (le_seq_quad32_to_bytes s) == num_bytes) }
slice (le_seq_quad32_to_bytes s) 0 num_bytes;
};
()
) | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.GCM.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 ->
a128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
a_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p_num_bytes: Prims.nat ->
a_num_bytes: Prims.nat ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
j0_BE: Vale.Def.Types_s.quad32 ->
h: Vale.Def.Types_s.quad32 ->
enc_hash: Vale.Def.Types_s.quad32 ->
length_quad: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 <= p_num_bytes /\
p_num_bytes < FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 + 16 /\
FStar.Seq.Base.length a128 * 16 <= a_num_bytes /\
a_num_bytes < FStar.Seq.Base.length a128 * 16 + 16 /\ a_num_bytes < Vale.Def.Words_s.pow2_32 /\
FStar.Seq.Base.length p128x6 == FStar.Seq.Base.length c128x6 /\
FStar.Seq.Base.length p128 == FStar.Seq.Base.length c128 /\
FStar.Seq.Base.length p_bytes == 1 /\ FStar.Seq.Base.length c_bytes == 1 /\
FStar.Seq.Base.length a_bytes == 1 /\ Vale.AES.AES_s.is_aes_key_LE alg key /\
j0_BE == Vale.AES.GCM_s.compute_iv_BE h iv /\
h = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour 0 0 0 0) /\
p_num_bytes < Vale.Def.Words_s.pow2_32 /\ a_num_bytes < Vale.Def.Words_s.pow2_32 /\
length_quad ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Words_s.Mkfour 0 0 0 0)
(8 * a_num_bytes)
1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1 = j0_BE in
let ctr_BE_2 = Vale.AES.GCTR_s.inc32 j0_BE 1 in
let plain =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes
| _ -> FStar.Seq.Base.append p128x6 p128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes
| _ -> FStar.Seq.Base.append c128x6 c128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher_bound =
FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128 +
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> 1
| _ -> 0)
in
Vale.AES.GCTR.gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
(match a_num_bytes > FStar.Seq.Base.length a128 * 16 with
| true -> FStar.Seq.Base.append a128 a_bytes
| _ -> a128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let auth_input_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
a_num_bytes
in
let auth_padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in
let auth_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = FStar.Seq.Base.append (FStar.Seq.Base.append auth_quads c128x6) c128 in
let total_bytes = FStar.Seq.Base.length auth_quads * 16 + p_num_bytes in
let raw_quads =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true ->
let raw_quads = FStar.Seq.Base.append raw_quads c_bytes in
let input_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads)
0
total_bytes
in
let input_padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in
Vale.Def.Types_s.le_bytes_to_seq_quad32 input_padded_bytes
| _ -> raw_quads)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let final_quads =
FStar.Seq.Base.append raw_quads (FStar.Seq.Base.create 1 length_quad)
in
enc_hash ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1
(Vale.AES.GHash_s.ghash_LE h final_quads)
alg
key
0)))
(ensures
(let auth_raw_quads = FStar.Seq.Base.append a128 a_bytes in
let auth_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
a_num_bytes
in
let plain_raw_quads = FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes in
let plain_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads)
0
p_num_bytes
in
let cipher_raw_quads =
FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes
in
let cipher_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads)
0
p_num_bytes
in
FStar.Seq.Base.length auth_bytes < Vale.Def.Words_s.pow2_32 /\
FStar.Seq.Base.length plain_bytes < Vale.Def.Words_s.pow2_32 /\
cipher_bytes ==
FStar.Pervasives.Native.fst (Vale.AES.GCM_s.gcm_encrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
plain_bytes
auth_bytes) /\
Vale.Def.Types_s.le_quad32_to_bytes enc_hash ==
FStar.Pervasives.Native.snd (Vale.AES.GCM_s.gcm_encrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
plain_bytes
auth_bytes))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat32",
"Vale.Def.Types_s.quad32",
"Prims.nat",
"Vale.AES.GCM_s.supported_iv_LE",
"Prims.unit",
"Vale.AES.GCM.lemma_length_simplifier",
"FStar.Seq.Base.append",
"Prims.op_GreaterThan",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Prims.bool",
"Vale.AES.GCM.gcm_blocks_helper",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_32",
"Prims.eq2",
"Prims.int",
"Vale.AES.AES_s.is_aes_key_LE",
"Vale.AES.GCM_s.compute_iv_BE",
"Prims.op_Equality",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.Def.Types_s.insert_nat64",
"Vale.AES.GCTR.gctr_partial",
"Vale.AES.GCTR_s.gctr_encrypt_block",
"Vale.AES.GHash_s.ghash_LE",
"FStar.Seq.Base.create",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.Def.Words_s.nat8",
"Vale.AES.GCTR_s.pad_to_128_bits",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.AES.GCTR_s.inc32",
"Prims.squash",
"FStar.Pervasives.Native.fst",
"Vale.AES.GCM_s.gcm_encrypt_LE",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"Vale.Def.Types_s.le_quad32_to_bytes",
"FStar.Pervasives.Native.snd",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let gcm_blocks_helper_simplified
(alg: algorithm)
(key: seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32)
(p_num_bytes a_num_bytes: nat)
(iv: supported_iv_LE)
(j0_BE h enc_hash length_quad: quad32)
: Lemma
(requires
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\
length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad ==
reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0)))
(ensures
(let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\
cipher_bytes ==
fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) =
| gcm_blocks_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes
a_num_bytes iv j0_BE h enc_hash length_quad;
let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher_raw_quads:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes;
lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes;
lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes;
() | false |
Vale.AES.GCM.fst | Vale.AES.GCM.lemma_compute_iv_easy | val lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma
(requires
length iv_extra_b == 1 /\
length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\
num_bytes == 96/8 /\
(let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in
j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\
(let raw_quads = append iv_b iv_extra_b in
let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in
iv_bytes == iv))
(ensures j0 == compute_iv_BE h_LE iv) | val lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma
(requires
length iv_extra_b == 1 /\
length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\
num_bytes == 96/8 /\
(let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in
j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\
(let raw_quads = append iv_b iv_extra_b in
let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in
iv_bytes == iv))
(ensures j0 == compute_iv_BE h_LE iv) | let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma
(requires
length iv_extra_b == 1 /\
length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\
num_bytes == 96/8 /\
(let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in
j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\
(let raw_quads = append iv_b iv_extra_b in
let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in
iv_bytes == iv))
(ensures j0 == compute_iv_BE h_LE iv)
=
assert (length iv == 12);
assert (length iv_b == 0);
lemma_empty iv_b;
append_empty_l iv_extra_b;
assert (append iv_b iv_extra_b == iv_extra_b);
let q = index iv_extra_b 0 in
le_seq_quad32_to_bytes_of_singleton q;
assert (equal iv_extra_b (create 1 q));
assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q);
// Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below
calc (==) {
slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12;
== {}
slice (pad_to_128_bits iv) 0 12;
};
// Prove this so we can call lemma_set_to_one_reverse_equality below
calc (==) {
le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits iv);
};
calc (==) {
j0;
== {}
set_to_one_LE (reverse_bytes_quad32 q);
== { le_bytes_to_quad32_to_bytes q }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q)));
== {
lemma_le_seq_quad32_to_bytes_prefix_equality q;
lemma_le_bytes_to_quad32_prefix_equality
(le_quad32_to_bytes q)
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12));
lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (le_quad32_to_bytes q))
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
}
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))));
== { lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
(le_bytes_to_quad32 (pad_to_128_bits iv));
lemma_le_bytes_to_quad32_prefix_equality
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))
(pad_to_128_bits iv) }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv)));
== {compute_iv_BE_reveal ()}
compute_iv_BE h_LE iv;
};
() | {
"file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 121,
"start_col": 0,
"start_line": 57
} | module Vale.AES.GCM
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.GCM_s
open Vale.AES.AES_s
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GHash_s
open FStar.Mul
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Calc
open Vale.Def.Words.Four_s
let lemma_set_to_one_equality (q0 q1:quad32) : Lemma
(requires upper3_equal q0 q1)
(ensures set_to_one_LE q0 == set_to_one_LE q1)
=
()
let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma
(requires lower3_equal q0 q1)
(ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1))
=
reveal_reverse_bytes_quad32 q0;
reveal_reverse_bytes_quad32 q1;
()
let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma
(requires slice b0 0 12 == slice b1 0 12)
(ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1))
=
let q0 = le_bytes_to_quad32 b0 in
let q1 = le_bytes_to_quad32 b1 in
le_bytes_to_quad32_reveal ();
(*
* AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this?
*)
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\
index b1 i == index (slice b1 0 12) i))
let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma
(slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
=
assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
(slice (le_quad32_to_bytes q) 0 12));
() | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.GCM.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
iv_b: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
iv_extra_b: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
num_bytes: Vale.Def.Words_s.nat64 ->
h_LE: Vale.Def.Types_s.quad32 ->
j0: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length iv_extra_b == 1 /\ FStar.Seq.Base.length iv_b * (128 / 8) <= num_bytes /\
num_bytes < FStar.Seq.Base.length iv_b * (128 / 8) + 128 / 8 /\ num_bytes == 96 / 8 /\
(let iv_BE = Vale.Def.Types_s.reverse_bytes_quad32 (FStar.Seq.Base.index iv_extra_b 0) in
j0 ==
Vale.Def.Words_s.Mkfour 1 (Mkfour?.lo1 iv_BE) (Mkfour?.hi2 iv_BE) (Mkfour?.hi3 iv_BE)) /\
(let raw_quads = FStar.Seq.Base.append iv_b iv_extra_b in
let iv_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 num_bytes
in
iv_bytes == iv)) (ensures j0 == Vale.AES.GCM_s.compute_iv_BE h_LE iv) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Vale.AES.GCM_s.supported_iv_LE",
"Vale.Def.Words_s.nat64",
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Vale.AES.GCM_s.compute_iv_BE",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Vale.AES.GCM.set_to_one_LE",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.Def.Types_s.le_bytes_to_quad32",
"Vale.AES.GCTR_s.pad_to_128_bits",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.le_quad32_to_bytes",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Vale.Arch.Types.le_bytes_to_quad32_to_bytes",
"Vale.AES.GCM.lemma_set_to_one_reverse_equality",
"Vale.AES.GCM.lemma_le_bytes_to_quad32_prefix_equality",
"Vale.AES.GCM.lemma_le_seq_quad32_to_bytes_prefix_equality",
"Vale.AES.GCM_s.compute_iv_BE_reveal",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.create",
"Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton",
"FStar.Seq.Base.index",
"FStar.Seq.Base.append",
"FStar.Seq.Base.append_empty_l",
"FStar.Seq.Base.lemma_empty",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Prims.op_Division",
"Prims.op_LessThan",
"Prims.op_Addition",
"Vale.Def.Words_s.four",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Words_s.nat8",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let lemma_compute_iv_easy
(iv_b iv_extra_b: seq quad32)
(iv: supported_iv_LE)
(num_bytes: nat64)
(h_LE j0: quad32)
: Lemma
(requires
length iv_extra_b == 1 /\ length iv_b * (128 / 8) <= num_bytes /\
num_bytes < length iv_b * (128 / 8) + 128 / 8 /\ num_bytes == 96 / 8 /\
(let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in
j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\
(let raw_quads = append iv_b iv_extra_b in
let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in
iv_bytes == iv)) (ensures j0 == compute_iv_BE h_LE iv) =
| assert (length iv == 12);
assert (length iv_b == 0);
lemma_empty iv_b;
append_empty_l iv_extra_b;
assert (append iv_b iv_extra_b == iv_extra_b);
let q = index iv_extra_b 0 in
le_seq_quad32_to_bytes_of_singleton q;
assert (equal iv_extra_b (create 1 q));
assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q);
calc ( == ) {
slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12;
( == ) { () }
slice (pad_to_128_bits iv) 0 12;
};
calc ( == ) {
le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes));
( == ) { () }
le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes));
( == ) { () }
le_bytes_to_quad32 (pad_to_128_bits iv);
};
calc ( == ) {
j0;
( == ) { () }
set_to_one_LE (reverse_bytes_quad32 q);
( == ) { le_bytes_to_quad32_to_bytes q }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q)));
( == ) { (lemma_le_seq_quad32_to_bytes_prefix_equality q;
lemma_le_bytes_to_quad32_prefix_equality (le_quad32_to_bytes q)
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12));
lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (le_quad32_to_bytes q))
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))) }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes
q)
0
12))));
( == ) { (lemma_set_to_one_reverse_equality (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes
q)
0
12)))
(le_bytes_to_quad32 (pad_to_128_bits iv));
lemma_le_bytes_to_quad32_prefix_equality (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))
(pad_to_128_bits iv)) }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv)));
( == ) { compute_iv_BE_reveal () }
compute_iv_BE h_LE iv;
};
() | false |
Steel.ST.OnRange.fsti | Steel.ST.OnRange.on_range_snoc_with_implies | val on_range_snoc_with_implies (#opened: _) (p: (nat -> vprop)) (i j j' k: nat)
: STGhost unit
opened
((on_range p i j) `star` (p j'))
(fun _ ->
(on_range p i k) `star` ((on_range p i k) `implies_` ((on_range p i j) `star` (p j'))))
(j' == j /\ k == j + 1)
(fun _ -> True) | val on_range_snoc_with_implies (#opened: _) (p: (nat -> vprop)) (i j j' k: nat)
: STGhost unit
opened
((on_range p i j) `star` (p j'))
(fun _ ->
(on_range p i k) `star` ((on_range p i k) `implies_` ((on_range p i j) `star` (p j'))))
(j' == j /\ k == j + 1)
(fun _ -> True) | let on_range_snoc_with_implies
(#opened: _)
(p: (nat -> vprop))
(i j j' k: nat)
: STGhost unit opened
(on_range p i j `star` p j')
(fun _ -> on_range p i k `star` (on_range p i k `implies_` (on_range p i j `star` p j')))
(j' == j /\ k == j + 1)
(fun _ -> True)
= on_range_le p i j;
on_range_snoc p i j j' k;
intro_implies
(on_range p i k)
(on_range p i j `star` p j')
emp
(fun _ ->
on_range_unsnoc p i j k;
rewrite (p j) (p j')
) | {
"file_name": "lib/steel/Steel.ST.OnRange.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 5,
"end_line": 152,
"start_col": 0,
"start_line": 134
} | module Steel.ST.OnRange
include Steel.ST.Util
val on_range (p: (nat -> vprop)) (i j: nat) : vprop
val on_range_le
(#opened: _)
(p: (nat -> vprop))
(i j: nat)
: STGhost unit opened
(on_range p i j)
(fun _ -> on_range p i j)
True
(fun _ -> i <= j)
val on_range_empty
(#opened: _)
(p: (nat -> vprop))
(i: nat)
(j: nat)
: STGhost unit opened
emp
(fun _ -> on_range p i j)
(i == j)
(fun _ -> True)
val on_range_singleton_intro
(#opened: _)
(p: (nat -> vprop))
(i: nat)
(j: nat)
: STGhost unit opened
(p i)
(fun _ -> on_range p i j)
(j == i + 1)
(fun _ -> True)
val on_range_singleton_elim
(#opened: _)
(p: (nat -> vprop))
(i j: nat)
: STGhost unit opened
(on_range p i j)
(fun _ -> p i)
(j == i + 1)
(fun _ -> True)
val on_range_split
(#opened: _)
(p: (nat -> vprop))
(i j k: nat)
: STGhost unit opened
(on_range p i k)
(fun _ -> on_range p i j `star` on_range p j k)
(i <= j /\ j <= k)
(fun _ -> True)
val on_range_join
(#opened: _)
(p: (nat -> vprop))
(i j k: nat)
: STGhostT unit opened
(on_range p i j `star` on_range p j k)
(fun _ -> on_range p i k)
let on_range_cons
(#opened: _)
(p: (nat -> vprop))
(i j k: nat)
: STGhost unit opened
(p i `star` on_range p j k)
(fun _ -> on_range p i k)
(j == i + 1)
(fun _ -> True)
= on_range_singleton_intro p i j;
on_range_join p i j k
let on_range_uncons
(#opened: _)
(p: (nat -> vprop))
(i j k: nat)
: STGhost unit opened
(on_range p i k)
(fun _ -> p i `star` on_range p j k)
(j == i + 1 /\ j <= k)
(fun _ -> True)
= on_range_split p i j k;
on_range_singleton_elim p i j
let on_range_cons_with_implies
(#opened: _)
(p: (nat -> vprop))
(i j k: nat)
: STGhost unit opened
(p i `star` on_range p j k)
(fun _ -> on_range p i k `star`
(on_range p i k @==> (p i `star` on_range p j k))
)
(j == i + 1)
(fun _ -> True)
= on_range_le p j k;
on_range_cons p i j k;
intro_implies
(on_range p i k)
(p i `star` on_range p j k)
emp
(fun _ -> on_range_uncons p i j k)
let on_range_snoc
(#opened: _)
(p: (nat -> vprop))
(i j j' k: nat)
: STGhost unit opened
(on_range p i j `star` p j')
(fun _ -> on_range p i k)
(j' == j /\ k == j + 1)
(fun _ -> True)
= rewrite (p j') (p j);
on_range_singleton_intro p j k;
on_range_join p i j k
let on_range_unsnoc
(#opened: _)
(p: (nat -> vprop))
(i j k: nat)
: STGhost unit opened
(on_range p i k)
(fun _ -> on_range p i j `star` p j)
(i <= j /\ k == j + 1)
(fun _ -> True)
= on_range_split p i j k;
on_range_singleton_elim p j k | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.OnRange.fsti"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: (_: Prims.nat -> Steel.Effect.Common.vprop) ->
i: Prims.nat ->
j: Prims.nat ->
j': Prims.nat ->
k: Prims.nat
-> Steel.ST.Effect.Ghost.STGhost Prims.unit | Steel.ST.Effect.Ghost.STGhost | [] | [] | [
"Steel.Memory.inames",
"Prims.nat",
"Steel.Effect.Common.vprop",
"Steel.ST.Util.intro_implies",
"Steel.ST.OnRange.on_range",
"Steel.Effect.Common.star",
"Steel.Effect.Common.emp",
"Steel.ST.Util.rewrite",
"Prims.unit",
"Steel.ST.OnRange.on_range_unsnoc",
"Steel.ST.OnRange.on_range_snoc",
"Steel.ST.OnRange.on_range_le",
"Steel.ST.Util.implies_",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"Prims.op_Addition",
"Prims.l_True"
] | [] | false | true | false | false | false | let on_range_snoc_with_implies (#opened: _) (p: (nat -> vprop)) (i j j' k: nat)
: STGhost unit
opened
((on_range p i j) `star` (p j'))
(fun _ ->
(on_range p i k) `star` ((on_range p i k) `implies_` ((on_range p i j) `star` (p j'))))
(j' == j /\ k == j + 1)
(fun _ -> True) =
| on_range_le p i j;
on_range_snoc p i j j' k;
intro_implies (on_range p i k)
((on_range p i j) `star` (p j'))
emp
(fun _ ->
on_range_unsnoc p i j k;
rewrite (p j) (p j')) | false |
Spec.HMAC_DRBG.fsti | Spec.HMAC_DRBG.is_supported_alg | val is_supported_alg : _: Spec.Hash.Definitions.hash_alg -> Prims.bool | let is_supported_alg = function
| SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false | {
"file_name": "specs/drbg/Spec.HMAC_DRBG.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 20,
"start_col": 0,
"start_line": 18
} | module Spec.HMAC_DRBG
open Lib.IntTypes
open FStar.Seq
open FStar.Mul
open Spec.Hash.Definitions
open Spec.Agile.HMAC
/// HMAC-DRBG
///
/// See 10.1.2 in
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
#set-options "--max_fuel 0 --max_ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.HMAC_DRBG.fsti"
} | [
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Spec.Hash.Definitions.hash_alg -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.bool"
] | [] | false | false | false | true | false | let is_supported_alg =
| function
| SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false | false |
|
Spec.HMAC_DRBG.fsti | Spec.HMAC_DRBG.reseed_interval | val reseed_interval : Prims.pos | let reseed_interval = pow2 10 | {
"file_name": "specs/drbg/Spec.HMAC_DRBG.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 24,
"start_col": 0,
"start_line": 24
} | module Spec.HMAC_DRBG
open Lib.IntTypes
open FStar.Seq
open FStar.Mul
open Spec.Hash.Definitions
open Spec.Agile.HMAC
/// HMAC-DRBG
///
/// See 10.1.2 in
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
#set-options "--max_fuel 0 --max_ifuel 0"
let is_supported_alg = function
| SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let supported_alg = a:hash_alg{ is_supported_alg a } | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.HMAC_DRBG.fsti"
} | [
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.pos | Prims.Tot | [
"total"
] | [] | [
"Prims.pow2"
] | [] | false | false | false | true | false | let reseed_interval =
| pow2 10 | false |
|
Spec.HMAC_DRBG.fsti | Spec.HMAC_DRBG.max_output_length | val max_output_length : Prims.pos | let max_output_length = pow2 16 | {
"file_name": "specs/drbg/Spec.HMAC_DRBG.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 25,
"start_col": 0,
"start_line": 25
} | module Spec.HMAC_DRBG
open Lib.IntTypes
open FStar.Seq
open FStar.Mul
open Spec.Hash.Definitions
open Spec.Agile.HMAC
/// HMAC-DRBG
///
/// See 10.1.2 in
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
#set-options "--max_fuel 0 --max_ifuel 0"
let is_supported_alg = function
| SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let supported_alg = a:hash_alg{ is_supported_alg a } | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.HMAC_DRBG.fsti"
} | [
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.pos | Prims.Tot | [
"total"
] | [] | [
"Prims.pow2"
] | [] | false | false | false | true | false | let max_output_length =
| pow2 16 | false |
|
Spec.HMAC_DRBG.fsti | Spec.HMAC_DRBG.supported_alg | val supported_alg : Type0 | let supported_alg = a:hash_alg{ is_supported_alg a } | {
"file_name": "specs/drbg/Spec.HMAC_DRBG.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 22,
"start_col": 0,
"start_line": 22
} | module Spec.HMAC_DRBG
open Lib.IntTypes
open FStar.Seq
open FStar.Mul
open Spec.Hash.Definitions
open Spec.Agile.HMAC
/// HMAC-DRBG
///
/// See 10.1.2 in
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
#set-options "--max_fuel 0 --max_ifuel 0"
let is_supported_alg = function
| SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.HMAC_DRBG.fsti"
} | [
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.HMAC_DRBG.is_supported_alg"
] | [] | false | false | false | true | true | let supported_alg =
| a: hash_alg{is_supported_alg a} | false |
|
Spec.HMAC_DRBG.fsti | Spec.HMAC_DRBG.max_length | val max_length : Prims.pos | let max_length = pow2 16 | {
"file_name": "specs/drbg/Spec.HMAC_DRBG.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 26,
"start_col": 0,
"start_line": 26
} | module Spec.HMAC_DRBG
open Lib.IntTypes
open FStar.Seq
open FStar.Mul
open Spec.Hash.Definitions
open Spec.Agile.HMAC
/// HMAC-DRBG
///
/// See 10.1.2 in
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
#set-options "--max_fuel 0 --max_ifuel 0"
let is_supported_alg = function
| SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let supported_alg = a:hash_alg{ is_supported_alg a }
let reseed_interval = pow2 10 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.HMAC_DRBG.fsti"
} | [
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.pos | Prims.Tot | [
"total"
] | [] | [
"Prims.pow2"
] | [] | false | false | false | true | false | let max_length =
| pow2 16 | false |
|
Spec.HMAC_DRBG.fsti | Spec.HMAC_DRBG.max_additional_input_length | val max_additional_input_length : Prims.pos | let max_additional_input_length = pow2 16 | {
"file_name": "specs/drbg/Spec.HMAC_DRBG.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 28,
"start_col": 0,
"start_line": 28
} | module Spec.HMAC_DRBG
open Lib.IntTypes
open FStar.Seq
open FStar.Mul
open Spec.Hash.Definitions
open Spec.Agile.HMAC
/// HMAC-DRBG
///
/// See 10.1.2 in
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
#set-options "--max_fuel 0 --max_ifuel 0"
let is_supported_alg = function
| SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let supported_alg = a:hash_alg{ is_supported_alg a }
let reseed_interval = pow2 10
let max_output_length = pow2 16
let max_length = pow2 16 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.HMAC_DRBG.fsti"
} | [
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.pos | Prims.Tot | [
"total"
] | [] | [
"Prims.pow2"
] | [] | false | false | false | true | false | let max_additional_input_length =
| pow2 16 | false |
|
Spec.HMAC_DRBG.fsti | Spec.HMAC_DRBG.max_personalization_string_length | val max_personalization_string_length : Prims.pos | let max_personalization_string_length = pow2 16 | {
"file_name": "specs/drbg/Spec.HMAC_DRBG.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 27,
"start_col": 0,
"start_line": 27
} | module Spec.HMAC_DRBG
open Lib.IntTypes
open FStar.Seq
open FStar.Mul
open Spec.Hash.Definitions
open Spec.Agile.HMAC
/// HMAC-DRBG
///
/// See 10.1.2 in
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
#set-options "--max_fuel 0 --max_ifuel 0"
let is_supported_alg = function
| SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let supported_alg = a:hash_alg{ is_supported_alg a }
let reseed_interval = pow2 10
let max_output_length = pow2 16 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.HMAC_DRBG.fsti"
} | [
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.pos | Prims.Tot | [
"total"
] | [] | [
"Prims.pow2"
] | [] | false | false | false | true | false | let max_personalization_string_length =
| pow2 16 | false |
|
Spec.HMAC_DRBG.fsti | Spec.HMAC_DRBG.min_length | val min_length : a: Spec.HMAC_DRBG.supported_alg -> Prims.int | let min_length (a:supported_alg) =
match a with
| SHA1 -> 16
| SHA2_256 | SHA2_384 | SHA2_512 -> 32 | {
"file_name": "specs/drbg/Spec.HMAC_DRBG.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 35,
"start_col": 0,
"start_line": 32
} | module Spec.HMAC_DRBG
open Lib.IntTypes
open FStar.Seq
open FStar.Mul
open Spec.Hash.Definitions
open Spec.Agile.HMAC
/// HMAC-DRBG
///
/// See 10.1.2 in
/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
///
#set-options "--max_fuel 0 --max_ifuel 0"
let is_supported_alg = function
| SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true
| _ -> false
let supported_alg = a:hash_alg{ is_supported_alg a }
let reseed_interval = pow2 10
let max_output_length = pow2 16
let max_length = pow2 16
let max_personalization_string_length = pow2 16
let max_additional_input_length = pow2 16
/// See p.54 | {
"checked_file": "/",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.HMAC_DRBG.fsti"
} | [
{
"abbrev": false,
"full_module": "Spec.Agile.HMAC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.HMAC_DRBG.supported_alg -> Prims.int | Prims.Tot | [
"total"
] | [] | [
"Spec.HMAC_DRBG.supported_alg",
"Prims.int"
] | [] | false | false | false | true | false | let min_length (a: supported_alg) =
| match a with
| SHA1 -> 16
| SHA2_256 | SHA2_384 | SHA2_512 -> 32 | false |
|
Vale.AES.GCM.fst | Vale.AES.GCM.gcm_blocks_helper | val gcm_blocks_helper
(alg: algorithm)
(key: seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32)
(p_num_bytes a_num_bytes: nat)
(iv: supported_iv_LE)
(j0_BE h enc_hash length_quad: quad32)
: Lemma
(requires
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\
length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad ==
reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0)))
(ensures
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\
cipher_bytes ==
fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) | val gcm_blocks_helper
(alg: algorithm)
(key: seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32)
(p_num_bytes a_num_bytes: nat)
(iv: supported_iv_LE)
(j0_BE h enc_hash length_quad: quad32)
: Lemma
(requires
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\
length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad ==
reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0)))
(ensures
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\
cipher_bytes ==
fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) | let gcm_blocks_helper (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes)))
=
let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
let hash = ghash_LE h final_quads in
gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes iv j0_BE;
//assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain_bytes auth_input_bytes)); // Passes
calc (==) {
enc_hash;
== {}
gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0;
== {}
gctr_encrypt_block ctr_BE_1 hash alg key 0;
== {}
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== { aes_encrypt_LE_reveal () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== {}
quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1);
};
calc (==) {
gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key;
== { gctr_encrypt_one_block ctr_BE_1 hash alg key }
le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1)));
== {}
le_seq_quad32_to_bytes (create 1 enc_hash);
== { le_seq_quad32_to_bytes_of_singleton enc_hash }
le_quad32_to_bytes enc_hash;
};
if p_num_bytes > (length p128x6 + length p128) * 16 then (
let c = append (append c128x6 c128) c_bytes in
calc (==) {
append (append (append auth_quads c128x6) c128) c_bytes;
== { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) c_bytes;
== { append_assoc auth_quads (append c128x6 c128) c_bytes }
append auth_quads (append (append c128x6 c128) c_bytes);
== {}
append auth_quads c;
};
calc (==) {
append (append (append (append auth_quads c128x6) c128) c_bytes) (create 1 length_quad);
= {} // See previous calc
append (append auth_quads (append (append c128x6 c128) c_bytes)) (create 1 length_quad);
== { append_assoc auth_quads c (create 1 length_quad) }
append auth_quads (append c (create 1 length_quad));
};
let raw_quads_old = append auth_quads c in
calc (==) {
raw_quads;
== {}
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes));
== {
calc (==) {
pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes);
== {
calc (==) {
slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes;
== { append_distributes_le_seq_quad32_to_bytes auth_quads c }
slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes;
== { slice_append_back (le_seq_quad32_to_bytes auth_quads)
(le_seq_quad32_to_bytes c)
total_bytes }
append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes);
== {}
append (le_seq_quad32_to_bytes auth_quads) cipher_bytes;
}
}
pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) cipher_bytes);
== { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) cipher_bytes }
append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes);
}
}
le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes));
== { append_distributes_le_bytes_to_seq_quad32
(le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits cipher_bytes) }
append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
== { le_bytes_to_seq_quad32_to_bytes auth_quads }
append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
};
let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in
let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes) in
calc (==) {
append raw_quads (create 1 length_quad);
== {}
append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes))) (create 1 length_quad);
== { assert (equal auth_quads auth_padded_quads') }
append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad);
== { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) }
append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad));
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key;
()
) else (
calc (==) {
append (append (append auth_quads c128x6) c128) (create 1 length_quad);
== { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) (create 1 length_quad);
== { append_assoc auth_quads (append c128x6 c128) (create 1 length_quad) }
append auth_quads (append (append c128x6 c128) (create 1 length_quad));
};
let c = append c128x6 c128 in
calc (==) {
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes));
== { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) }
le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c));
== { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) }
le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c);
== { le_bytes_to_seq_quad32_to_bytes c }
c;
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key;
()
);
() | {
"file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 585,
"start_col": 0,
"start_line": 333
} | module Vale.AES.GCM
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.GCM_s
open Vale.AES.AES_s
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GHash_s
open FStar.Mul
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Calc
open Vale.Def.Words.Four_s
let lemma_set_to_one_equality (q0 q1:quad32) : Lemma
(requires upper3_equal q0 q1)
(ensures set_to_one_LE q0 == set_to_one_LE q1)
=
()
let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma
(requires lower3_equal q0 q1)
(ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1))
=
reveal_reverse_bytes_quad32 q0;
reveal_reverse_bytes_quad32 q1;
()
let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma
(requires slice b0 0 12 == slice b1 0 12)
(ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1))
=
let q0 = le_bytes_to_quad32 b0 in
let q1 = le_bytes_to_quad32 b1 in
le_bytes_to_quad32_reveal ();
(*
* AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this?
*)
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\
index b1 i == index (slice b1 0 12) i))
let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma
(slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
=
assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
(slice (le_quad32_to_bytes q) 0 12));
()
let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma
(requires
length iv_extra_b == 1 /\
length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\
num_bytes == 96/8 /\
(let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in
j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\
(let raw_quads = append iv_b iv_extra_b in
let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in
iv_bytes == iv))
(ensures j0 == compute_iv_BE h_LE iv)
=
assert (length iv == 12);
assert (length iv_b == 0);
lemma_empty iv_b;
append_empty_l iv_extra_b;
assert (append iv_b iv_extra_b == iv_extra_b);
let q = index iv_extra_b 0 in
le_seq_quad32_to_bytes_of_singleton q;
assert (equal iv_extra_b (create 1 q));
assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q);
// Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below
calc (==) {
slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12;
== {}
slice (pad_to_128_bits iv) 0 12;
};
// Prove this so we can call lemma_set_to_one_reverse_equality below
calc (==) {
le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits iv);
};
calc (==) {
j0;
== {}
set_to_one_LE (reverse_bytes_quad32 q);
== { le_bytes_to_quad32_to_bytes q }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q)));
== {
lemma_le_seq_quad32_to_bytes_prefix_equality q;
lemma_le_bytes_to_quad32_prefix_equality
(le_quad32_to_bytes q)
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12));
lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (le_quad32_to_bytes q))
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
}
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))));
== { lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
(le_bytes_to_quad32 (pad_to_128_bits iv));
lemma_le_bytes_to_quad32_prefix_equality
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))
(pad_to_128_bits iv) }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv)));
== {compute_iv_BE_reveal ()}
compute_iv_BE h_LE iv;
};
()
open Vale.AES.GHash
let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma
(requires
~(length iv == 96/8) /\
quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\
j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\
length_quad == reverse_bytes_quad32 (insert_nat64
(insert_nat64
(Mkfour 0 0 0 0) 0 1)
(8 * (length iv)) 0))
(ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv)
=
assert (two_to_nat32 (Mktwo 0 0) == 0);
let q0 = Mkfour 0 0 0 0 in
lemma_insert_nat64_nat32s q0 0 0;
assert (insert_nat64 q0 0 1 == q0);
insert_nat64_reveal ();
assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0));
ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad));
compute_iv_BE_reveal ();
()
let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\
cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\
length plain < pow2_32 /\
length auth < pow2_32
))
(ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
=
gcm_encrypt_LE_reveal ()
(*
let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in
let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in
let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in
let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in
be_bytes_to_quad32_to_bytes iv_BE;
assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE);
assert (s_iv_BE == iv_BE);
assert (s_key_LE == key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE ==
gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key ==
gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key ==
gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key);
()
*)
let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv /\
length plain < pow2_32 /\
length auth < pow2_32 /\
cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\
length_quad32 == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\
(let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\
le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key)
))
(ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
=
insert_nat64_reveal ();
gcm_encrypt_LE_reveal ()
//be_bytes_to_quad32_to_bytes iv_BE;
//let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in
//()
#reset-options "--z3rlimit 10"
let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32)
(p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(auth_bytes:seq nat8)
(p_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
(length auth_bytes) < pow2_32 /\
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\
(let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2
)))
(ensures (let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
//cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key))
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)))
=
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
gctr_partial_opaque_completed alg plain cipher key ctr_BE_2;
if p_num_bytes > (length p128x6 + length p128) * 16 then (
gctr_partial_reveal ();
assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2);
assert (equal (slice plain 0 (length p128x6 + length p128))
(slice (append p128x6 p128) 0 (length p128x6 + length p128)));
assert (equal (slice cipher 0 (length p128x6 + length p128))
(slice (append c128x6 c128) 0 (length p128x6 + length p128)));
gctr_partial_opaque_ignores_postfix
alg (length p128x6 + length p128)
plain (append p128x6 p128)
cipher (append c128x6 c128)
key ctr_BE_2;
assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2);
gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2;
let num_blocks = p_num_bytes / 16 in
assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks)));
gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks;
assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks ==
gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0);
aes_encrypt_LE_reveal ();
gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes;
assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)
) else (
gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher;
assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key);
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
assert (equal plain_bytes (le_seq_quad32_to_bytes plain));
assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher));
assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)
);
gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key;
()
let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma
(requires length x <= i /\ i <= length x + length y)
(ensures slice (append x y) 0 i == append x (slice y 0 (i - length x)))
=
assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x))));
()
let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) :
Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y))
=
append_distributes_le_seq_quad32_to_bytes x y
let pad_to_128_bits_multiple_append (x y:seq nat8) : Lemma
(requires length x % 16 == 0)
(ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y))
=
assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y))) | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.GCM.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 ->
a128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
a_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p_num_bytes: Prims.nat ->
a_num_bytes: Prims.nat ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
j0_BE: Vale.Def.Types_s.quad32 ->
h: Vale.Def.Types_s.quad32 ->
enc_hash: Vale.Def.Types_s.quad32 ->
length_quad: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 <= p_num_bytes /\
p_num_bytes < FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 + 16 /\
FStar.Seq.Base.length a128 * 16 <= a_num_bytes /\
a_num_bytes < FStar.Seq.Base.length a128 * 16 + 16 /\ a_num_bytes < Vale.Def.Words_s.pow2_32 /\
FStar.Seq.Base.length p128x6 == FStar.Seq.Base.length c128x6 /\
FStar.Seq.Base.length p128 == FStar.Seq.Base.length c128 /\
FStar.Seq.Base.length p_bytes == 1 /\ FStar.Seq.Base.length c_bytes == 1 /\
FStar.Seq.Base.length a_bytes == 1 /\ Vale.AES.AES_s.is_aes_key_LE alg key /\
j0_BE = Vale.AES.GCM_s.compute_iv_BE h iv /\
h = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour 0 0 0 0) /\
p_num_bytes < Vale.Def.Words_s.pow2_32 /\ a_num_bytes < Vale.Def.Words_s.pow2_32 /\
length_quad ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Words_s.Mkfour 0 0 0 0)
(8 * a_num_bytes)
1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1 = j0_BE in
let ctr_BE_2 = Vale.AES.GCTR_s.inc32 j0_BE 1 in
let plain =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes
| _ -> FStar.Seq.Base.append p128x6 p128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes
| _ -> FStar.Seq.Base.append c128x6 c128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher_bound =
FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128 +
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> 1
| _ -> 0)
in
Vale.AES.GCTR.gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
(match a_num_bytes > FStar.Seq.Base.length a128 * 16 with
| true -> FStar.Seq.Base.append a128 a_bytes
| _ -> a128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let auth_input_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
a_num_bytes
in
let auth_padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in
let auth_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = FStar.Seq.Base.append (FStar.Seq.Base.append auth_quads c128x6) c128 in
let total_bytes = FStar.Seq.Base.length auth_quads * 16 + p_num_bytes in
let raw_quads =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true ->
let raw_quads = FStar.Seq.Base.append raw_quads c_bytes in
let input_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads)
0
total_bytes
in
let input_padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in
Vale.Def.Types_s.le_bytes_to_seq_quad32 input_padded_bytes
| _ -> raw_quads)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let final_quads =
FStar.Seq.Base.append raw_quads (FStar.Seq.Base.create 1 length_quad)
in
enc_hash ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1
(Vale.AES.GHash_s.ghash_LE h final_quads)
alg
key
0)))
(ensures
(let auth_raw_quads =
(match a_num_bytes > FStar.Seq.Base.length a128 * 16 with
| true -> FStar.Seq.Base.append a128 a_bytes
| _ -> a128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let auth_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
a_num_bytes
in
let plain_raw_quads =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes
| _ -> FStar.Seq.Base.append p128x6 p128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let plain_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads)
0
p_num_bytes
in
let cipher =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes
| _ -> FStar.Seq.Base.append c128x6 c128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher) 0 p_num_bytes
in
FStar.Seq.Base.length auth_bytes < Vale.Def.Words_s.pow2_32 /\
FStar.Seq.Base.length plain_bytes < Vale.Def.Words_s.pow2_32 /\
cipher_bytes ==
FStar.Pervasives.Native.fst (Vale.AES.GCM_s.gcm_encrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
plain_bytes
auth_bytes) /\
Vale.Def.Types_s.le_quad32_to_bytes enc_hash ==
FStar.Pervasives.Native.snd (Vale.AES.GCM_s.gcm_encrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
plain_bytes
auth_bytes))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat32",
"Vale.Def.Types_s.quad32",
"Prims.nat",
"Vale.AES.GCM_s.supported_iv_LE",
"Prims.unit",
"Prims.op_GreaterThan",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Vale.AES.GCM.gcm_encrypt_LE_snd_helper",
"Vale.Def.Types_s.insert_nat64_reveal",
"FStar.Calc.calc_finish",
"Prims.eq2",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.AES.GCTR_s.pad_to_128_bits",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.append_assoc",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.Def.Types_s.nat8",
"FStar.Seq.Base.slice",
"Vale.AES.GCM.append_distributes_le_seq_quad32_to_bytes",
"Vale.AES.GCM.slice_append_back",
"Vale.AES.GCM.pad_to_128_bits_multiple_append",
"Vale.Arch.Types.append_distributes_le_bytes_to_seq_quad32",
"Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.bool",
"Vale.AES.GCTR_s.gctr_encrypt_LE",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.GCTR.aes_encrypt_BE",
"Vale.AES.GCTR.gctr_encrypt_one_block",
"Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AES.GCTR_s.gctr_encrypt_block",
"Vale.AES.GHash_s.ghash_LE",
"Vale.AES.AES_s.aes_encrypt_LE_reveal",
"Vale.AES.GCM.gcm_blocks_helper_enc",
"Vale.Def.Words_s.nat8",
"Prims.int",
"Vale.AES.GCTR_s.inc32",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_32",
"Vale.AES.AES_s.is_aes_key_LE",
"Vale.AES.GCM_s.compute_iv_BE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.insert_nat64",
"Vale.AES.GCTR.gctr_partial",
"FStar.Pervasives.Native.fst",
"Vale.AES.GCM_s.gcm_encrypt_LE",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"FStar.Pervasives.Native.snd",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let gcm_blocks_helper
(alg: algorithm)
(key: seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32)
(p_num_bytes a_num_bytes: nat)
(iv: supported_iv_LE)
(j0_BE h enc_hash length_quad: quad32)
: Lemma
(requires
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\
length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad ==
reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0)))
(ensures
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\
cipher_bytes ==
fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) =
| let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
let hash = ghash_LE h final_quads in
gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes
iv j0_BE;
calc ( == ) {
enc_hash;
( == ) { () }
gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0;
( == ) { () }
gctr_encrypt_block ctr_BE_1 hash alg key 0;
( == ) { () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
( == ) { aes_encrypt_LE_reveal () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
( == ) { () }
quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1);
};
calc ( == ) {
gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key;
( == ) { gctr_encrypt_one_block ctr_BE_1 hash alg key }
le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1)));
( == ) { () }
le_seq_quad32_to_bytes (create 1 enc_hash);
( == ) { le_seq_quad32_to_bytes_of_singleton enc_hash }
le_quad32_to_bytes enc_hash;
};
if p_num_bytes > (length p128x6 + length p128) * 16
then
(let c = append (append c128x6 c128) c_bytes in
calc ( == ) {
append (append (append auth_quads c128x6) c128) c_bytes;
( == ) { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) c_bytes;
( == ) { append_assoc auth_quads (append c128x6 c128) c_bytes }
append auth_quads (append (append c128x6 c128) c_bytes);
( == ) { () }
append auth_quads c;
};
calc ( == ) {
append (append (append (append auth_quads c128x6) c128) c_bytes) (create 1 length_quad);
( = ) { () }
append (append auth_quads (append (append c128x6 c128) c_bytes)) (create 1 length_quad);
( == ) { append_assoc auth_quads c (create 1 length_quad) }
append auth_quads (append c (create 1 length_quad));
};
let raw_quads_old = append auth_quads c in
calc ( == ) {
raw_quads;
( == ) { () }
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old)
0
total_bytes));
( == ) { calc ( == ) {
pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes);
( == ) { calc ( == ) {
slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes;
( == ) { append_distributes_le_seq_quad32_to_bytes auth_quads c }
slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c))
0
total_bytes;
( == ) { slice_append_back (le_seq_quad32_to_bytes auth_quads)
(le_seq_quad32_to_bytes c)
total_bytes }
append (le_seq_quad32_to_bytes auth_quads)
(slice (le_seq_quad32_to_bytes c) 0 p_num_bytes);
( == ) { () }
append (le_seq_quad32_to_bytes auth_quads) cipher_bytes;
} }
pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) cipher_bytes);
( == ) { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) cipher_bytes }
append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes);
} }
le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits cipher_bytes));
( == ) { append_distributes_le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits cipher_bytes) }
append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads))
(le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
( == ) { le_bytes_to_seq_quad32_to_bytes auth_quads }
append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
};
let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in
let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes) in
calc ( == ) {
append raw_quads (create 1 length_quad);
( == ) { () }
append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes)))
(create 1 length_quad);
( == ) { assert (equal auth_quads auth_padded_quads') }
append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad);
( == ) { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) }
append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad));
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes
cipher_bytes alg key;
())
else
(calc ( == ) {
append (append (append auth_quads c128x6) c128) (create 1 length_quad);
( == ) { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) (create 1 length_quad);
( == ) { append_assoc auth_quads (append c128x6 c128) (create 1 length_quad) }
append auth_quads (append (append c128x6 c128) (create 1 length_quad));
};
let c = append c128x6 c128 in
calc ( == ) {
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes));
( == ) { assert (equal (le_seq_quad32_to_bytes c)
(slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) }
le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c));
( == ) { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) }
le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c);
( == ) { le_bytes_to_seq_quad32_to_bytes c }
c;
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes
cipher_bytes alg key;
());
() | false |
Vale.AES.GCM.fst | Vale.AES.GCM.gcm_blocks_dec_helper | val gcm_blocks_dec_helper
(alg: algorithm)
(key: seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32)
(p_num_bytes a_num_bytes: nat)
(iv: supported_iv_LE)
(j0_BE h enc_hash length_quad: quad32)
: Lemma
(requires
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\
length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad ==
reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0)))
(ensures
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\
le_quad32_to_bytes enc_hash ==
gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)) | val gcm_blocks_dec_helper
(alg: algorithm)
(key: seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32)
(p_num_bytes a_num_bytes: nat)
(iv: supported_iv_LE)
(j0_BE h enc_hash length_quad: quad32)
: Lemma
(requires
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\
length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad ==
reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0)))
(ensures
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\
le_quad32_to_bytes enc_hash ==
gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)) | let gcm_blocks_dec_helper (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
le_quad32_to_bytes enc_hash == gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes))
=
insert_nat64_reveal ();
let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
let hash = ghash_LE h final_quads in
//gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes j0_BE;
//assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes j0_BE) plain_bytes auth_input_bytes)); // Passes
calc (==) {
enc_hash;
== {}
gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0;
== {}
gctr_encrypt_block ctr_BE_1 hash alg key 0;
== {}
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== { aes_encrypt_LE_reveal () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== {}
quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1);
};
calc (==) {
gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key;
== { gctr_encrypt_one_block ctr_BE_1 hash alg key }
le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1)));
== {}
le_seq_quad32_to_bytes (create 1 enc_hash);
== { le_seq_quad32_to_bytes_of_singleton enc_hash }
le_quad32_to_bytes enc_hash;
};
if p_num_bytes > (length p128x6 + length p128) * 16 then (
let c = append (append p128x6 p128) p_bytes in
calc (==) {
append (append (append auth_quads p128x6) p128) p_bytes;
== { append_assoc auth_quads p128x6 p128 }
append (append auth_quads (append p128x6 p128)) p_bytes;
== { append_assoc auth_quads (append p128x6 p128) p_bytes }
append auth_quads (append (append p128x6 p128) p_bytes);
== {}
append auth_quads c;
};
calc (==) {
append (append (append (append auth_quads p128x6) p128) p_bytes) (create 1 length_quad);
= {} // See previous calc
append (append auth_quads (append (append p128x6 p128) p_bytes)) (create 1 length_quad);
== { append_assoc auth_quads c (create 1 length_quad) }
append auth_quads (append c (create 1 length_quad));
};
let raw_quads_old = append auth_quads c in
calc (==) {
raw_quads;
== {}
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes));
== {
calc (==) {
pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes);
== {
calc (==) {
slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes;
== { append_distributes_le_seq_quad32_to_bytes auth_quads c }
slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes;
== { slice_append_back (le_seq_quad32_to_bytes auth_quads)
(le_seq_quad32_to_bytes c)
total_bytes }
append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes);
== { assert(equal (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes) plain_bytes) }
append (le_seq_quad32_to_bytes auth_quads) plain_bytes;
}
}
pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) plain_bytes);
== { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) plain_bytes }
append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits plain_bytes);
}
}
le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits plain_bytes));
== { append_distributes_le_bytes_to_seq_quad32
(le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits plain_bytes) }
append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes));
== { le_bytes_to_seq_quad32_to_bytes auth_quads }
append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes));
};
let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in
let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes) in
calc (==) {
append raw_quads (create 1 length_quad);
== {}
append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes))) (create 1 length_quad);
== { assert (equal auth_quads auth_padded_quads') }
append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad);
== { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) }
append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad));
};
()
) else (
calc (==) {
append (append (append auth_quads p128x6) p128) (create 1 length_quad);
== { append_assoc auth_quads p128x6 p128 }
append (append auth_quads (append p128x6 p128)) (create 1 length_quad);
== { append_assoc auth_quads (append p128x6 p128) (create 1 length_quad) }
append auth_quads (append (append p128x6 p128) (create 1 length_quad));
};
let c = append p128x6 p128 in
calc (==) {
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes));
== { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) }
le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c));
== { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) }
le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c);
== { le_bytes_to_seq_quad32_to_bytes c }
c;
};
()
);
() | {
"file_name": "vale/code/crypto/aes/Vale.AES.GCM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 1047,
"start_col": 0,
"start_line": 801
} | module Vale.AES.GCM
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.AES.GCM_s
open Vale.AES.AES_s
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GHash_s
open FStar.Mul
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Calc
open Vale.Def.Words.Four_s
let lemma_set_to_one_equality (q0 q1:quad32) : Lemma
(requires upper3_equal q0 q1)
(ensures set_to_one_LE q0 == set_to_one_LE q1)
=
()
let lemma_set_to_one_reverse_equality (q0 q1:quad32) : Lemma
(requires lower3_equal q0 q1)
(ensures set_to_one_LE (reverse_bytes_quad32 q0) == set_to_one_LE (reverse_bytes_quad32 q1))
=
reveal_reverse_bytes_quad32 q0;
reveal_reverse_bytes_quad32 q1;
()
let lemma_le_bytes_to_quad32_prefix_equality (b0:seq nat8 {length b0 == 16}) (b1:seq nat8 {length b1 == 16}) : Lemma
(requires slice b0 0 12 == slice b1 0 12)
(ensures lower3_equal (le_bytes_to_quad32 b0) (le_bytes_to_quad32 b1))
=
let q0 = le_bytes_to_quad32 b0 in
let q1 = le_bytes_to_quad32 b1 in
le_bytes_to_quad32_reveal ();
(*
* AR: 06/25: Someone should review this code, is this proof supposed to work without revealing this?
*)
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
assert (forall (i:int). (0 <= i /\ i < 12) ==> (index b0 i == index (slice b0 0 12) i /\
index b1 i == index (slice b1 0 12) i))
let lemma_le_seq_quad32_to_bytes_prefix_equality (q:quad32) : Lemma
(slice (le_quad32_to_bytes q) 0 12 == slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
=
assert (equal (slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12)
(slice (le_quad32_to_bytes q) 0 12));
()
let lemma_compute_iv_easy (iv_b iv_extra_b:seq quad32) (iv:supported_iv_LE) (num_bytes:nat64) (h_LE j0:quad32) : Lemma
(requires
length iv_extra_b == 1 /\
length iv_b * (128/8) <= num_bytes /\ num_bytes < length iv_b * (128/8) + 128/8 /\
num_bytes == 96/8 /\
(let iv_BE = reverse_bytes_quad32 (index iv_extra_b 0) in
j0 == Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3) /\
(let raw_quads = append iv_b iv_extra_b in
let iv_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 num_bytes in
iv_bytes == iv))
(ensures j0 == compute_iv_BE h_LE iv)
=
assert (length iv == 12);
assert (length iv_b == 0);
lemma_empty iv_b;
append_empty_l iv_extra_b;
assert (append iv_b iv_extra_b == iv_extra_b);
let q = index iv_extra_b 0 in
le_seq_quad32_to_bytes_of_singleton q;
assert (equal iv_extra_b (create 1 q));
assert (le_seq_quad32_to_bytes iv_extra_b == le_quad32_to_bytes q);
// Prove this so we can call lemma_le_bytes_to_quad32_prefix_equality below
calc (==) {
slice (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)) 0 12;
== {}
slice (pad_to_128_bits iv) 0 12;
};
// Prove this so we can call lemma_set_to_one_reverse_equality below
calc (==) {
le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes iv_extra_b) 0 num_bytes));
== {}
le_bytes_to_quad32 (pad_to_128_bits iv);
};
calc (==) {
j0;
== {}
set_to_one_LE (reverse_bytes_quad32 q);
== { le_bytes_to_quad32_to_bytes q }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (le_quad32_to_bytes q)));
== {
lemma_le_seq_quad32_to_bytes_prefix_equality q;
lemma_le_bytes_to_quad32_prefix_equality
(le_quad32_to_bytes q)
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12));
lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (le_quad32_to_bytes q))
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
}
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))));
== { lemma_set_to_one_reverse_equality
(le_bytes_to_quad32 (pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12)))
(le_bytes_to_quad32 (pad_to_128_bits iv));
lemma_le_bytes_to_quad32_prefix_equality
(pad_to_128_bits (slice (le_quad32_to_bytes q) 0 12))
(pad_to_128_bits iv) }
set_to_one_LE (reverse_bytes_quad32 (le_bytes_to_quad32 (pad_to_128_bits iv)));
== {compute_iv_BE_reveal ()}
compute_iv_BE h_LE iv;
};
()
open Vale.AES.GHash
let lemma_compute_iv_hard (iv:supported_iv_LE) (quads:seq quad32) (length_quad h_LE j0:quad32) : Lemma
(requires
~(length iv == 96/8) /\
quads == le_bytes_to_seq_quad32 (pad_to_128_bits iv) /\
j0 == ghash_incremental h_LE (Mkfour 0 0 0 0) (append quads (create 1 length_quad)) /\
length_quad == reverse_bytes_quad32 (insert_nat64
(insert_nat64
(Mkfour 0 0 0 0) 0 1)
(8 * (length iv)) 0))
(ensures reverse_bytes_quad32 j0 == compute_iv_BE h_LE iv)
=
assert (two_to_nat32 (Mktwo 0 0) == 0);
let q0 = Mkfour 0 0 0 0 in
lemma_insert_nat64_nat32s q0 0 0;
assert (insert_nat64 q0 0 1 == q0);
insert_nat64_reveal ();
assert (length_quad == reverse_bytes_quad32 (insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0));
ghash_incremental_to_ghash h_LE (append quads (create 1 length_quad));
compute_iv_BE_reveal ();
()
let gcm_encrypt_LE_fst_helper (iv:supported_iv_LE) (iv_enc iv_BE:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
iv_enc == inc32 (compute_iv_BE h_LE iv) 1 /\
cipher == gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key /\
length plain < pow2_32 /\
length auth < pow2_32
))
(ensures cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
=
gcm_encrypt_LE_reveal ()
(*
let s_key_LE = seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE key) in
let s_iv_BE = be_bytes_to_quad32 (be_quad32_to_bytes iv_BE) in
let s_j0_BE = Mkfour 1 s_iv_BE.lo1 s_iv_BE.hi2 s_iv_BE.hi3 in
let s_cipher = fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in
be_bytes_to_quad32_to_bytes iv_BE;
assert (s_cipher == gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE);
assert (s_iv_BE == iv_BE);
assert (s_key_LE == key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg s_key_LE ==
gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) plain alg key ==
gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key);
assert (gctr_encrypt_LE (inc32 s_j0_BE 1) (make_gctr_plain_LE plain) alg key ==
gctr_encrypt_LE iv_enc (make_gctr_plain_LE plain) alg key);
()
*)
let gcm_encrypt_LE_snd_helper (iv:supported_iv_LE) (j0_BE length_quad32 hash mac:quad32) (plain auth cipher:seq nat8) (alg:algorithm) (key:seq nat32) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv /\
length plain < pow2_32 /\
length auth < pow2_32 /\
cipher == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth) /\
length_quad32 == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0) /\
(let auth_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in
let cipher_padded_quads = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in
hash == ghash_LE h_LE (append auth_padded_quads (append cipher_padded_quads (create 1 length_quad32))) /\
le_quad32_to_bytes mac == gctr_encrypt_LE j0_BE (le_quad32_to_bytes hash) alg key)
))
(ensures le_quad32_to_bytes mac == snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain auth))
=
insert_nat64_reveal ();
gcm_encrypt_LE_reveal ()
//be_bytes_to_quad32_to_bytes iv_BE;
//let t = snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain auth) in
//()
#reset-options "--z3rlimit 10"
let gcm_blocks_helper_enc (alg:algorithm) (key:seq nat32)
(p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(auth_bytes:seq nat8)
(p_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
(length auth_bytes) < pow2_32 /\
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\
(let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2
)))
(ensures (let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
//cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key))
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)))
=
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
gctr_partial_opaque_completed alg plain cipher key ctr_BE_2;
if p_num_bytes > (length p128x6 + length p128) * 16 then (
gctr_partial_reveal ();
assert (gctr_partial alg (length p128x6 + length p128) plain cipher key ctr_BE_2);
assert (equal (slice plain 0 (length p128x6 + length p128))
(slice (append p128x6 p128) 0 (length p128x6 + length p128)));
assert (equal (slice cipher 0 (length p128x6 + length p128))
(slice (append c128x6 c128) 0 (length p128x6 + length p128)));
gctr_partial_opaque_ignores_postfix
alg (length p128x6 + length p128)
plain (append p128x6 p128)
cipher (append c128x6 c128)
key ctr_BE_2;
assert (gctr_partial alg (length p128x6 + length p128) (append p128x6 p128) (append c128x6 c128) key ctr_BE_2);
gctr_partial_opaque_completed alg (append p128x6 p128) (append c128x6 c128) key ctr_BE_2;
let num_blocks = p_num_bytes / 16 in
assert(index cipher num_blocks == quad32_xor (index plain num_blocks) (aes_encrypt_BE alg key (inc32 ctr_BE_2 num_blocks)));
gctr_encrypt_block_offset ctr_BE_2 (index plain num_blocks) alg key num_blocks;
assert( gctr_encrypt_block ctr_BE_2 (index plain num_blocks) alg key num_blocks ==
gctr_encrypt_block (inc32 ctr_BE_2 num_blocks) (index plain num_blocks) alg key 0);
aes_encrypt_LE_reveal ();
gctr_partial_to_full_advanced ctr_BE_2 plain cipher alg key p_num_bytes;
assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)
) else (
gctr_partial_to_full_basic ctr_BE_2 plain alg key cipher;
assert (le_seq_quad32_to_bytes cipher == gctr_encrypt_LE ctr_BE_2 (le_seq_quad32_to_bytes plain) alg key);
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
assert (equal plain_bytes (le_seq_quad32_to_bytes plain));
assert (equal cipher_bytes (le_seq_quad32_to_bytes cipher));
assert (cipher_bytes == gctr_encrypt_LE ctr_BE_2 plain_bytes alg key)
);
gcm_encrypt_LE_fst_helper iv ctr_BE_2 j0_BE plain_bytes auth_bytes cipher_bytes alg key;
()
let slice_append_back (#a:Type) (x y:seq a) (i:nat) : Lemma
(requires length x <= i /\ i <= length x + length y)
(ensures slice (append x y) 0 i == append x (slice y 0 (i - length x)))
=
assert (equal (slice (append x y) 0 i) (append x (slice y 0 (i - length x))));
()
let append_distributes_le_seq_quad32_to_bytes (x y:seq quad32) :
Lemma (le_seq_quad32_to_bytes (append x y) == append (le_seq_quad32_to_bytes x) (le_seq_quad32_to_bytes y))
=
append_distributes_le_seq_quad32_to_bytes x y
let pad_to_128_bits_multiple_append (x y:seq nat8) : Lemma
(requires length x % 16 == 0)
(ensures pad_to_128_bits (append x y) == append x (pad_to_128_bits y))
=
assert (equal (pad_to_128_bits (append x y)) (append x (pad_to_128_bits y)))
#reset-options "--z3rlimit 100"
let gcm_blocks_helper (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes)))
=
let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
let hash = ghash_LE h final_quads in
gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_input_bytes p_num_bytes iv j0_BE;
//assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) (be_quad32_to_bytes iv_BE) plain_bytes auth_input_bytes)); // Passes
calc (==) {
enc_hash;
== {}
gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0;
== {}
gctr_encrypt_block ctr_BE_1 hash alg key 0;
== {}
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== { aes_encrypt_LE_reveal () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
== {}
quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1);
};
calc (==) {
gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key;
== { gctr_encrypt_one_block ctr_BE_1 hash alg key }
le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1)));
== {}
le_seq_quad32_to_bytes (create 1 enc_hash);
== { le_seq_quad32_to_bytes_of_singleton enc_hash }
le_quad32_to_bytes enc_hash;
};
if p_num_bytes > (length p128x6 + length p128) * 16 then (
let c = append (append c128x6 c128) c_bytes in
calc (==) {
append (append (append auth_quads c128x6) c128) c_bytes;
== { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) c_bytes;
== { append_assoc auth_quads (append c128x6 c128) c_bytes }
append auth_quads (append (append c128x6 c128) c_bytes);
== {}
append auth_quads c;
};
calc (==) {
append (append (append (append auth_quads c128x6) c128) c_bytes) (create 1 length_quad);
= {} // See previous calc
append (append auth_quads (append (append c128x6 c128) c_bytes)) (create 1 length_quad);
== { append_assoc auth_quads c (create 1 length_quad) }
append auth_quads (append c (create 1 length_quad));
};
let raw_quads_old = append auth_quads c in
calc (==) {
raw_quads;
== {}
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes));
== {
calc (==) {
pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes);
== {
calc (==) {
slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes;
== { append_distributes_le_seq_quad32_to_bytes auth_quads c }
slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c)) 0 total_bytes;
== { slice_append_back (le_seq_quad32_to_bytes auth_quads)
(le_seq_quad32_to_bytes c)
total_bytes }
append (le_seq_quad32_to_bytes auth_quads) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes);
== {}
append (le_seq_quad32_to_bytes auth_quads) cipher_bytes;
}
}
pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) cipher_bytes);
== { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) cipher_bytes }
append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes);
}
}
le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits cipher_bytes));
== { append_distributes_le_bytes_to_seq_quad32
(le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits cipher_bytes) }
append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)) (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
== { le_bytes_to_seq_quad32_to_bytes auth_quads }
append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes));
};
let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in
let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes) in
calc (==) {
append raw_quads (create 1 length_quad);
== {}
append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits cipher_bytes))) (create 1 length_quad);
== { assert (equal auth_quads auth_padded_quads') }
append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad);
== { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) }
append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad));
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key;
()
) else (
calc (==) {
append (append (append auth_quads c128x6) c128) (create 1 length_quad);
== { append_assoc auth_quads c128x6 c128 }
append (append auth_quads (append c128x6 c128)) (create 1 length_quad);
== { append_assoc auth_quads (append c128x6 c128) (create 1 length_quad) }
append auth_quads (append (append c128x6 c128) (create 1 length_quad));
};
let c = append c128x6 c128 in
calc (==) {
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes));
== { assert (equal (le_seq_quad32_to_bytes c) (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) }
le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c));
== { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) }
le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c);
== { le_bytes_to_seq_quad32_to_bytes c }
c;
};
insert_nat64_reveal ();
gcm_encrypt_LE_snd_helper iv j0_BE length_quad hash enc_hash plain_bytes auth_input_bytes cipher_bytes alg key;
()
);
()
// TODO: remove duplicate code -- there is an identical copy of this in GCTR.fst
let lemma_length_simplifier (s bytes t:seq quad32) (num_bytes:nat) : Lemma
(requires t == (if num_bytes > (length s) * 16 then append s bytes else s) /\
(num_bytes <= (length s) * 16 ==> num_bytes == (length s * 16)) /\
length s * 16 <= num_bytes /\
num_bytes < length s * 16 + 16 /\
length bytes == 1
)
(ensures slice (le_seq_quad32_to_bytes t) 0 num_bytes ==
slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes)
=
if num_bytes > (length s) * 16 then (
()
) else (
calc (==) {
slice (le_seq_quad32_to_bytes (append s bytes)) 0 num_bytes;
== { append_distributes_le_seq_quad32_to_bytes s bytes }
slice (append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes)) 0 num_bytes;
== { Vale.Lib.Seqs.lemma_slice_first_exactly_in_append (le_seq_quad32_to_bytes s) (le_seq_quad32_to_bytes bytes) }
le_seq_quad32_to_bytes s;
== { assert (length (le_seq_quad32_to_bytes s) == num_bytes) }
slice (le_seq_quad32_to_bytes s) 0 num_bytes;
};
()
)
#reset-options "--z3rlimit 10"
let gcm_blocks_helper_simplified (alg:algorithm) (key:seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(p_num_bytes a_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE h enc_hash length_quad:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\
a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
length a_bytes == 1 /\
is_aes_key_LE alg key /\
j0_BE == compute_iv_BE h iv /\
h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad == reverse_bytes_quad32
(insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1) (8 * p_num_bytes) 0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads c128x6) c128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
let raw_quads = append raw_quads c_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else
raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0
)))
(ensures (let auth_raw_quads = append a128 a_bytes in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes) /\
le_quad32_to_bytes enc_hash ==
snd (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key)
iv plain_bytes auth_bytes))
)
=
gcm_blocks_helper alg key a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes p_num_bytes a_num_bytes iv j0_BE h enc_hash length_quad;
let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher_raw_quads:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
lemma_length_simplifier a128 a_bytes auth_raw_quads a_num_bytes;
lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes;
lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes;
()
let lemma_gcm_encrypt_decrypt_equiv (alg:algorithm) (key:seq nat32) (iv:supported_iv_LE) (j0_BE:quad32) (plain cipher auth alleged_tag:seq nat8) : Lemma
(requires
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv) /\
length cipher < pow2_32 /\
length auth < pow2_32 /\
plain == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth)
)
(ensures plain == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv cipher auth alleged_tag))
=
gcm_encrypt_LE_reveal ();
gcm_decrypt_LE_reveal ();
()
let gcm_blocks_helper_dec_simplified (alg:algorithm) (key:seq nat32)
(p128x6 p128 p_bytes c128x6 c128 c_bytes:seq quad32)
(auth_bytes alleged_tag:seq nat8)
(p_num_bytes:nat)
(iv:supported_iv_LE) (j0_BE:quad32) : Lemma
(requires // Required by gcm_blocks
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\
length p128x6 == length c128x6 /\
length p128 == length c128 /\
length p_bytes == 1 /\
length c_bytes == 1 /\
(length auth_bytes) < pow2_32 /\
is_aes_key_LE alg key /\
(let h_LE = aes_encrypt_LE alg key (Mkfour 0 0 0 0) in
j0_BE = compute_iv_BE h_LE iv) /\
// Ensured by gcm_blocks
p_num_bytes < pow2_32 /\
(let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else
append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
let cipher_bound:nat = length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2
))
(ensures (let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
length auth_bytes < pow2_32 /\
length plain_bytes < pow2_32 /\
cipher_bytes == fst (gcm_decrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes alleged_tag)))
=
gcm_blocks_helper_enc alg key p128x6 p128 p_bytes c128x6 c128 c_bytes auth_bytes p_num_bytes iv j0_BE;
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher_raw_quads:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16 then
append (append c128x6 c128) c_bytes
else
append c128x6 c128
in
lemma_length_simplifier (append p128x6 p128) p_bytes plain_raw_quads p_num_bytes;
lemma_length_simplifier (append c128x6 c128) c_bytes cipher_raw_quads p_num_bytes;
let plain_raw_quads = append (append p128x6 p128) p_bytes in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher_raw_quads = append (append c128x6 c128) c_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher_raw_quads) 0 p_num_bytes in
assert (cipher_bytes == fst (gcm_encrypt_LE alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes));
lemma_gcm_encrypt_decrypt_equiv alg key iv j0_BE cipher_bytes plain_bytes auth_bytes alleged_tag;
() | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.GCM.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 ->
a128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
a_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c128x6: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c128: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
c_bytes: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
p_num_bytes: Prims.nat ->
a_num_bytes: Prims.nat ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
j0_BE: Vale.Def.Types_s.quad32 ->
h: Vale.Def.Types_s.quad32 ->
enc_hash: Vale.Def.Types_s.quad32 ->
length_quad: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 <= p_num_bytes /\
p_num_bytes < FStar.Seq.Base.length p128x6 * 16 + FStar.Seq.Base.length p128 * 16 + 16 /\
FStar.Seq.Base.length a128 * 16 <= a_num_bytes /\
a_num_bytes < FStar.Seq.Base.length a128 * 16 + 16 /\ a_num_bytes < Vale.Def.Words_s.pow2_32 /\
FStar.Seq.Base.length p128x6 == FStar.Seq.Base.length c128x6 /\
FStar.Seq.Base.length p128 == FStar.Seq.Base.length c128 /\
FStar.Seq.Base.length p_bytes == 1 /\ FStar.Seq.Base.length c_bytes == 1 /\
FStar.Seq.Base.length a_bytes == 1 /\ Vale.AES.AES_s.is_aes_key_LE alg key /\
j0_BE = Vale.AES.GCM_s.compute_iv_BE h iv /\
h = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour 0 0 0 0) /\
p_num_bytes < Vale.Def.Words_s.pow2_32 /\ a_num_bytes < Vale.Def.Words_s.pow2_32 /\
length_quad ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Words_s.Mkfour 0 0 0 0)
(8 * a_num_bytes)
1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1 = j0_BE in
let ctr_BE_2 = Vale.AES.GCTR_s.inc32 j0_BE 1 in
let plain =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes
| _ -> FStar.Seq.Base.append p128x6 p128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes
| _ -> FStar.Seq.Base.append c128x6 c128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher_bound =
FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128 +
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> 1
| _ -> 0)
in
Vale.AES.GCTR.gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
(match a_num_bytes > FStar.Seq.Base.length a128 * 16 with
| true -> FStar.Seq.Base.append a128 a_bytes
| _ -> a128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let auth_input_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
a_num_bytes
in
let auth_padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in
let auth_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = FStar.Seq.Base.append (FStar.Seq.Base.append auth_quads p128x6) p128 in
let total_bytes = FStar.Seq.Base.length auth_quads * 16 + p_num_bytes in
let raw_quads =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true ->
let raw_quads = FStar.Seq.Base.append raw_quads p_bytes in
let input_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads)
0
total_bytes
in
let input_padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in
Vale.Def.Types_s.le_bytes_to_seq_quad32 input_padded_bytes
| _ -> raw_quads)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let final_quads =
FStar.Seq.Base.append raw_quads (FStar.Seq.Base.create 1 length_quad)
in
enc_hash ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1
(Vale.AES.GHash_s.ghash_LE h final_quads)
alg
key
0)))
(ensures
(let auth_raw_quads =
(match a_num_bytes > FStar.Seq.Base.length a128 * 16 with
| true -> FStar.Seq.Base.append a128 a_bytes
| _ -> a128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let auth_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
a_num_bytes
in
let plain_raw_quads =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append p128x6 p128) p_bytes
| _ -> FStar.Seq.Base.append p128x6 p128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let plain_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads)
0
p_num_bytes
in
let cipher =
(match
p_num_bytes > (FStar.Seq.Base.length p128x6 + FStar.Seq.Base.length p128) * 16
with
| true -> FStar.Seq.Base.append (FStar.Seq.Base.append c128x6 c128) c_bytes
| _ -> FStar.Seq.Base.append c128x6 c128)
<:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32
in
let cipher_bytes =
FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher) 0 p_num_bytes
in
FStar.Seq.Base.length auth_bytes < Vale.Def.Words_s.pow2_32 /\
FStar.Seq.Base.length plain_bytes < Vale.Def.Words_s.pow2_32 /\
Vale.Def.Types_s.le_quad32_to_bytes enc_hash ==
Vale.AES.GCM.gcm_decrypt_LE_tag alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
plain_bytes
auth_bytes)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat32",
"Vale.Def.Types_s.quad32",
"Prims.nat",
"Vale.AES.GCM_s.supported_iv_LE",
"Prims.unit",
"Prims.op_GreaterThan",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"FStar.Calc.calc_finish",
"Prims.eq2",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.AES.GCTR_s.pad_to_128_bits",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.append_assoc",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.Def.Types_s.nat8",
"FStar.Seq.Base.slice",
"Vale.AES.GCM.append_distributes_le_seq_quad32_to_bytes",
"Vale.AES.GCM.slice_append_back",
"Vale.AES.GCM.pad_to_128_bits_multiple_append",
"Vale.Arch.Types.append_distributes_le_bytes_to_seq_quad32",
"Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.bool",
"Vale.AES.GCTR_s.gctr_encrypt_LE",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.GCTR.aes_encrypt_BE",
"Vale.AES.GCTR.gctr_encrypt_one_block",
"Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AES.GCTR_s.gctr_encrypt_block",
"Vale.AES.GHash_s.ghash_LE",
"Vale.AES.AES_s.aes_encrypt_LE_reveal",
"Vale.Def.Words_s.nat8",
"Prims.int",
"Vale.AES.GCTR_s.inc32",
"Vale.Def.Types_s.insert_nat64_reveal",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Vale.Def.Words_s.pow2_32",
"Vale.AES.AES_s.is_aes_key_LE",
"Vale.AES.GCM_s.compute_iv_BE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.insert_nat64",
"Vale.AES.GCTR.gctr_partial",
"Vale.AES.GCM.gcm_decrypt_LE_tag",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let gcm_blocks_dec_helper
(alg: algorithm)
(key: seq nat32)
(a128 a_bytes p128x6 p128 p_bytes c128x6 c128 c_bytes: seq quad32)
(p_num_bytes a_num_bytes: nat)
(iv: supported_iv_LE)
(j0_BE h enc_hash length_quad: quad32)
: Lemma
(requires
length p128x6 * 16 + length p128 * 16 <= p_num_bytes /\
p_num_bytes < length p128x6 * 16 + length p128 * 16 + 16 /\ length a128 * 16 <= a_num_bytes /\
a_num_bytes < length a128 * 16 + 16 /\ a_num_bytes < pow2_32 /\
length p128x6 == length c128x6 /\ length p128 == length c128 /\ length p_bytes == 1 /\
length c_bytes == 1 /\ length a_bytes == 1 /\ is_aes_key_LE alg key /\
j0_BE = compute_iv_BE h iv /\ h = aes_encrypt_LE alg key (Mkfour 0 0 0 0) /\
p_num_bytes < pow2_32 /\ a_num_bytes < pow2_32 /\
length_quad ==
reverse_bytes_quad32 (insert_nat64 (insert_nat64 (Mkfour 0 0 0 0) (8 * a_num_bytes) 1)
(8 * p_num_bytes)
0) /\
(let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 +
(if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
gctr_partial alg cipher_bound plain cipher key ctr_BE_2 /\
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
enc_hash == gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0)))
(ensures
(let auth_raw_quads =
if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128
in
let auth_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let plain_raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain_raw_quads) 0 p_num_bytes in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
length auth_bytes < pow2_32 /\ length plain_bytes < pow2_32 /\
le_quad32_to_bytes enc_hash ==
gcm_decrypt_LE_tag alg (seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes)) =
| insert_nat64_reveal ();
let ctr_BE_1:quad32 = j0_BE in
let ctr_BE_2:quad32 = inc32 j0_BE 1 in
let plain:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append p128x6 p128) p_bytes
else append p128x6 p128
in
let cipher:seq quad32 =
if p_num_bytes > (length p128x6 + length p128) * 16
then append (append c128x6 c128) c_bytes
else append c128x6 c128
in
let cipher_bound:nat =
length p128x6 + length p128 + (if p_num_bytes > (length p128x6 + length p128) * 16 then 1 else 0)
in
let plain_bytes = slice (le_seq_quad32_to_bytes plain) 0 p_num_bytes in
let cipher_bytes = slice (le_seq_quad32_to_bytes cipher) 0 p_num_bytes in
let auth_raw_quads = if a_num_bytes > (length a128) * 16 then append a128 a_bytes else a128 in
let auth_input_bytes = slice (le_seq_quad32_to_bytes auth_raw_quads) 0 a_num_bytes in
let auth_padded_bytes = pad_to_128_bits auth_input_bytes in
let auth_quads = le_bytes_to_seq_quad32 auth_padded_bytes in
let raw_quads = append (append auth_quads p128x6) p128 in
let total_bytes = (length auth_quads) * 16 + p_num_bytes in
let raw_quads =
if p_num_bytes > (length p128x6 + length p128) * 16
then
let raw_quads = append raw_quads p_bytes in
let input_bytes = slice (le_seq_quad32_to_bytes raw_quads) 0 total_bytes in
let input_padded_bytes = pad_to_128_bits input_bytes in
le_bytes_to_seq_quad32 input_padded_bytes
else raw_quads
in
let final_quads = append raw_quads (create 1 length_quad) in
let hash = ghash_LE h final_quads in
calc ( == ) {
enc_hash;
( == ) { () }
gctr_encrypt_block ctr_BE_1 (ghash_LE h final_quads) alg key 0;
( == ) { () }
gctr_encrypt_block ctr_BE_1 hash alg key 0;
( == ) { () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
( == ) { aes_encrypt_LE_reveal () }
quad32_xor hash (aes_encrypt_LE alg key (reverse_bytes_quad32 ctr_BE_1));
( == ) { () }
quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1);
};
calc ( == ) {
gctr_encrypt_LE ctr_BE_1 (le_quad32_to_bytes hash) alg key;
( == ) { gctr_encrypt_one_block ctr_BE_1 hash alg key }
le_seq_quad32_to_bytes (create 1 (quad32_xor hash (aes_encrypt_BE alg key ctr_BE_1)));
( == ) { () }
le_seq_quad32_to_bytes (create 1 enc_hash);
( == ) { le_seq_quad32_to_bytes_of_singleton enc_hash }
le_quad32_to_bytes enc_hash;
};
if p_num_bytes > (length p128x6 + length p128) * 16
then
(let c = append (append p128x6 p128) p_bytes in
calc ( == ) {
append (append (append auth_quads p128x6) p128) p_bytes;
( == ) { append_assoc auth_quads p128x6 p128 }
append (append auth_quads (append p128x6 p128)) p_bytes;
( == ) { append_assoc auth_quads (append p128x6 p128) p_bytes }
append auth_quads (append (append p128x6 p128) p_bytes);
( == ) { () }
append auth_quads c;
};
calc ( == ) {
append (append (append (append auth_quads p128x6) p128) p_bytes) (create 1 length_quad);
( = ) { () }
append (append auth_quads (append (append p128x6 p128) p_bytes)) (create 1 length_quad);
( == ) { append_assoc auth_quads c (create 1 length_quad) }
append auth_quads (append c (create 1 length_quad));
};
let raw_quads_old = append auth_quads c in
calc ( == ) {
raw_quads;
( == ) { () }
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old)
0
total_bytes));
( == ) { calc ( == ) {
pad_to_128_bits (slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes);
( == ) { calc ( == ) {
slice (le_seq_quad32_to_bytes raw_quads_old) 0 total_bytes;
( == ) { append_distributes_le_seq_quad32_to_bytes auth_quads c }
slice (append (le_seq_quad32_to_bytes auth_quads) (le_seq_quad32_to_bytes c))
0
total_bytes;
( == ) { slice_append_back (le_seq_quad32_to_bytes auth_quads)
(le_seq_quad32_to_bytes c)
total_bytes }
append (le_seq_quad32_to_bytes auth_quads)
(slice (le_seq_quad32_to_bytes c) 0 p_num_bytes);
( == ) { assert (equal (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes) plain_bytes) }
append (le_seq_quad32_to_bytes auth_quads) plain_bytes;
} }
pad_to_128_bits (append (le_seq_quad32_to_bytes auth_quads) plain_bytes);
( == ) { pad_to_128_bits_multiple_append (le_seq_quad32_to_bytes auth_quads) plain_bytes }
append (le_seq_quad32_to_bytes auth_quads) (pad_to_128_bits plain_bytes);
} }
le_bytes_to_seq_quad32 (append (le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits plain_bytes));
( == ) { append_distributes_le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads)
(pad_to_128_bits plain_bytes) }
append (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes auth_quads))
(le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes));
( == ) { le_bytes_to_seq_quad32_to_bytes auth_quads }
append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes));
};
let auth_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits auth_input_bytes) in
let cipher_padded_quads' = le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes) in
calc ( == ) {
append raw_quads (create 1 length_quad);
( == ) { () }
append (append auth_quads (le_bytes_to_seq_quad32 (pad_to_128_bits plain_bytes)))
(create 1 length_quad);
( == ) { assert (equal auth_quads auth_padded_quads') }
append (append auth_padded_quads' cipher_padded_quads') (create 1 length_quad);
( == ) { append_assoc auth_padded_quads' cipher_padded_quads' (create 1 length_quad) }
append auth_padded_quads' (append cipher_padded_quads' (create 1 length_quad));
};
())
else
(calc ( == ) {
append (append (append auth_quads p128x6) p128) (create 1 length_quad);
( == ) { append_assoc auth_quads p128x6 p128 }
append (append auth_quads (append p128x6 p128)) (create 1 length_quad);
( == ) { append_assoc auth_quads (append p128x6 p128) (create 1 length_quad) }
append auth_quads (append (append p128x6 p128) (create 1 length_quad));
};
let c = append p128x6 p128 in
calc ( == ) {
le_bytes_to_seq_quad32 (pad_to_128_bits (slice (le_seq_quad32_to_bytes c) 0 p_num_bytes));
( == ) { assert (equal (le_seq_quad32_to_bytes c)
(slice (le_seq_quad32_to_bytes c) 0 p_num_bytes)) }
le_bytes_to_seq_quad32 (pad_to_128_bits (le_seq_quad32_to_bytes c));
( == ) { assert (pad_to_128_bits (le_seq_quad32_to_bytes c) == (le_seq_quad32_to_bytes c)) }
le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes c);
( == ) { le_bytes_to_seq_quad32_to_bytes c }
c;
};
());
() | false |
EverParse3d.Util.fst | EverParse3d.Util.solve_from_ctx | val solve_from_ctx: Prims.unit -> Tac unit | val solve_from_ctx: Prims.unit -> Tac unit | let solve_from_ctx () : Tac unit =
ignore (intros ());
let bs = vars_of_env (cur_env ()) in
first (map (fun (b:binding) () -> exact b) bs) | {
"file_name": "src/3d/prelude/EverParse3d.Util.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 48,
"end_line": 8,
"start_col": 0,
"start_line": 5
} | module EverParse3d.Util
open FStar.Tactics.V2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Util.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 0,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.unit",
"FStar.Tactics.V2.Derived.first",
"Prims.list",
"FStar.Tactics.Util.map",
"FStar.Tactics.NamedView.binding",
"FStar.Tactics.V2.Derived.exact",
"FStar.Tactics.V2.SyntaxCoercions.binding_to_term",
"FStar.Stubs.Reflection.V2.Data.binding",
"FStar.Stubs.Reflection.V2.Builtins.vars_of_env",
"FStar.Stubs.Reflection.Types.env",
"FStar.Tactics.V2.Derived.cur_env",
"FStar.Pervasives.ignore",
"FStar.Tactics.V2.Derived.intros"
] | [] | false | true | false | false | false | let solve_from_ctx () : Tac unit =
| ignore (intros ());
let bs = vars_of_env (cur_env ()) in
first (map (fun (b: binding) () -> exact b) bs) | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.le_to_n | val le_to_n (s:Seq.seq u8) : Tot nat | val le_to_n (s:Seq.seq u8) : Tot nat | let le_to_n s = E.le_to_n s | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 43,
"start_col": 0,
"start_line": 43
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq LowStar.PrefixFreezableBuffer.u8 -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"LowStar.PrefixFreezableBuffer.u8",
"FStar.Endianness.le_to_n",
"Prims.nat"
] | [] | false | false | false | true | false | let le_to_n s =
| E.le_to_n s | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.prefix_freezable_preorder | val prefix_freezable_preorder : srel u8 | val prefix_freezable_preorder : srel u8 | let prefix_freezable_preorder = pre | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 35,
"end_line": 45,
"start_col": 0,
"start_line": 45
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowStar.Monotonic.Buffer.srel LowStar.PrefixFreezableBuffer.u8 | Prims.Tot | [
"total"
] | [] | [
"LowStar.PrefixFreezableBuffer.pre"
] | [] | false | false | false | true | false | let prefix_freezable_preorder =
| pre | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.update_frozen_until_alloc | val update_frozen_until_alloc (b: mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack unit
(requires fun h -> live h b /\ length b >= 4 /\ frozen_until (as_seq h b) == 0)
(ensures
fun h0 _ h1 ->
live h1 b /\ modifies (loc_buffer b) h0 h1 /\ frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4)) | val update_frozen_until_alloc (b: mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack unit
(requires fun h -> live h b /\ length b >= 4 /\ frozen_until (as_seq h b) == 0)
(ensures
fun h0 _ h1 ->
live h1 b /\ modifies (loc_buffer b) h0 h1 /\ frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4)) | let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4) | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 41,
"end_line": 63,
"start_col": 8,
"start_line": 49
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b:
LowStar.Monotonic.Buffer.mbuffer LowStar.PrefixFreezableBuffer.u8
LowStar.PrefixFreezableBuffer.prefix_freezable_preorder
LowStar.PrefixFreezableBuffer.prefix_freezable_preorder
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"LowStar.Monotonic.Buffer.witness_p",
"LowStar.PrefixFreezableBuffer.frozen_until_at_least",
"Prims.unit",
"LowStar.Endianness.store32_le_i",
"FStar.UInt32.__uint_to_t",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"LowStar.Monotonic.Buffer.length",
"Prims.eq2",
"Prims.int",
"LowStar.PrefixFreezableBuffer.frozen_until",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Monotonic.Buffer.witnessed"
] | [] | false | true | false | false | false | let update_frozen_until_alloc (b: mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack unit
(requires fun h -> live h b /\ length b >= 4 /\ frozen_until (as_seq h b) == 0)
(ensures
fun h0 _ h1 ->
live h1 b /\ modifies (loc_buffer b) h0 h1 /\ frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4)) =
| LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4) | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.gcmalloc | val gcmalloc (r:HS.rid) (len:u32)
: ST (b:lbuffer len{frameOf b == r /\ recallable b})
(requires fun _ -> malloc_pre r len)
(ensures alloc_post_mem_common) | val gcmalloc (r:HS.rid) (len:u32)
: ST (b:lbuffer len{frameOf b == r /\ recallable b})
(requires fun _ -> malloc_pre r len)
(ensures alloc_post_mem_common) | let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 3,
"end_line": 74,
"start_col": 0,
"start_line": 65
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: FStar.Monotonic.HyperHeap.rid -> len: LowStar.PrefixFreezableBuffer.u32
-> FStar.HyperStack.ST.ST
(b:
LowStar.PrefixFreezableBuffer.lbuffer len
{LowStar.Monotonic.Buffer.frameOf b == r /\ LowStar.Monotonic.Buffer.recallable b}) | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperHeap.rid",
"LowStar.PrefixFreezableBuffer.u32",
"LowStar.PrefixFreezableBuffer.lbuffer",
"Prims.l_and",
"Prims.eq2",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"LowStar.PrefixFreezableBuffer.update_frozen_until_alloc",
"Prims._assert",
"LowStar.Monotonic.Buffer.fresh_loc",
"LowStar.Monotonic.Buffer.loc_buffer",
"FStar.Endianness.le_to_n_zeros",
"FStar.Seq.Base.slice",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"FStar.UInt32.add",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Monotonic.Buffer.mgcmalloc",
"FStar.UInt8.__uint_to_t",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.lmbuffer"
] | [] | false | true | false | false | false | let gcmalloc r len =
| let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in
E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h);
update_frozen_until_alloc b;
b | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.upd | val upd (b:buffer) (i:u32) (v:u8)
: Stack
unit
(requires fun h ->
live h b /\ U32.v i < length b /\
U32.v i >= frozen_until (as_seq h b))
(ensures fun h0 _ h1 ->
(not (g_is_null b)) /\
modifies (loc_buffer b) h0 h1 /\
live h1 b /\
frozen_until (as_seq h0 b) == frozen_until (as_seq h1 b) /\
as_seq h1 b == Seq.upd (as_seq h0 b) (U32.v i) v) | val upd (b:buffer) (i:u32) (v:u8)
: Stack
unit
(requires fun h ->
live h b /\ U32.v i < length b /\
U32.v i >= frozen_until (as_seq h b))
(ensures fun h0 _ h1 ->
(not (g_is_null b)) /\
modifies (loc_buffer b) h0 h1 /\
live h1 b /\
frozen_until (as_seq h0 b) == frozen_until (as_seq h1 b) /\
as_seq h1 b == Seq.upd (as_seq h0 b) (U32.v i) v) | let upd b i v =
recall_p b (frozen_until_at_least 4);
upd b i v | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 11,
"end_line": 100,
"start_col": 0,
"start_line": 98
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b: LowStar.PrefixFreezableBuffer.buffer ->
i: LowStar.PrefixFreezableBuffer.u32 ->
v: LowStar.PrefixFreezableBuffer.u8
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.PrefixFreezableBuffer.buffer",
"LowStar.PrefixFreezableBuffer.u32",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.Monotonic.Buffer.upd",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"Prims.unit",
"LowStar.Monotonic.Buffer.recall_p",
"LowStar.PrefixFreezableBuffer.frozen_until_at_least"
] | [] | false | true | false | false | false | let upd b i v =
| recall_p b (frozen_until_at_least 4);
upd b i v | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.alloca | val alloca (len:u32)
: StackInline
(lbuffer len)
(requires fun _ -> alloca_pre len)
(ensures fun h0 b h1 ->
alloc_post_mem_common h0 b h1 /\ frameOf b == HS.get_tip h0) | val alloca (len:u32)
: StackInline
(lbuffer len)
(requires fun _ -> alloca_pre len)
(ensures fun h0 b h1 ->
alloc_post_mem_common h0 b h1 /\ frameOf b == HS.get_tip h0) | let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 3,
"end_line": 96,
"start_col": 0,
"start_line": 87
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: LowStar.PrefixFreezableBuffer.u32
-> FStar.HyperStack.ST.StackInline (LowStar.PrefixFreezableBuffer.lbuffer len) | FStar.HyperStack.ST.StackInline | [] | [] | [
"LowStar.PrefixFreezableBuffer.u32",
"LowStar.PrefixFreezableBuffer.lbuffer",
"Prims.unit",
"LowStar.PrefixFreezableBuffer.update_frozen_until_alloc",
"Prims._assert",
"LowStar.Monotonic.Buffer.fresh_loc",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"FStar.Endianness.le_to_n_zeros",
"FStar.Seq.Base.slice",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"FStar.UInt32.add",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Monotonic.Buffer.malloca",
"FStar.UInt8.__uint_to_t",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.lmbuffer"
] | [] | false | true | false | false | false | let alloca len =
| let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in
E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h);
update_frozen_until_alloc b;
b | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.le_pre_post_index | val le_pre_post_index (s1 s2: Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\ Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1)) (Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i: nat). {:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==> (Seq.index s1 i == Seq.index s2 i))) | val le_pre_post_index (s1 s2: Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\ Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1)) (Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i: nat). {:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==> (Seq.index s1 i == Seq.index s2 i))) | let le_pre_post_index
(s1 s2:Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\
Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1))
(Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i:nat).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==>
(Seq.index s1 i == Seq.index s2 i)))
= assert (forall (s:Seq.seq u8).
Seq.length s >= 4 ==>
(forall (i:nat).
(i >= 4 /\ i < Seq.length s) ==>
Seq.index s i == Seq.index (Seq.slice s 4 (Seq.length s)) (i - 4))) | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 77,
"end_line": 125,
"start_col": 0,
"start_line": 108
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let upd b i v =
recall_p b (frozen_until_at_least 4);
upd b i v
(*
* This lemma handles the mismatch between the style of the spec
* in LE.store_pre and LE.store_post, and the preorder of PrefixFreezableBuffers
* Basically the sequence library is missing a lemma that eliminates
* equality on two slices to some equality on the base sequences | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s1: FStar.Seq.Base.seq LowStar.PrefixFreezableBuffer.u8 ->
s2: FStar.Seq.Base.seq LowStar.PrefixFreezableBuffer.u8
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.length s1 == FStar.Seq.Base.length s2 /\ FStar.Seq.Base.length s1 >= 4 /\
FStar.Seq.Base.equal (FStar.Seq.Base.slice s1 0 0) (FStar.Seq.Base.slice s2 0 0) /\
FStar.Seq.Base.equal (FStar.Seq.Base.slice s1 4 (FStar.Seq.Base.length s1))
(FStar.Seq.Base.slice s2 4 (FStar.Seq.Base.length s2)) ==>
(forall (i: Prims.nat). {:pattern FStar.Seq.Base.index s1 i; FStar.Seq.Base.index s2 i}
i >= 4 /\ i < FStar.Seq.Base.length s1 ==>
FStar.Seq.Base.index s1 i == FStar.Seq.Base.index s2 i)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"LowStar.PrefixFreezableBuffer.u8",
"Prims._assert",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Seq.Base.length",
"Prims.nat",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.eq2",
"FStar.Seq.Base.index",
"FStar.Seq.Base.slice",
"Prims.op_Subtraction",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"FStar.Seq.Base.equal",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let le_pre_post_index (s1 s2: Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\ Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1)) (Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i: nat). {:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==> (Seq.index s1 i == Seq.index s2 i))) =
| assert (forall (s: Seq.seq u8).
Seq.length s >= 4 ==>
(forall (i: nat).
(i >= 4 /\ i < Seq.length s) ==>
Seq.index s i == Seq.index (Seq.slice s 4 (Seq.length s)) (i - 4))) | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.malloc | val malloc (r:HS.rid) (len:u32)
: ST
(b:lbuffer len{frameOf b == r /\ freeable b})
(requires fun _ -> malloc_pre r len)
(ensures alloc_post_mem_common) | val malloc (r:HS.rid) (len:u32)
: ST
(b:lbuffer len{frameOf b == r /\ freeable b})
(requires fun _ -> malloc_pre r len)
(ensures alloc_post_mem_common) | let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 3,
"end_line": 85,
"start_col": 0,
"start_line": 76
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: FStar.Monotonic.HyperHeap.rid -> len: LowStar.PrefixFreezableBuffer.u32
-> FStar.HyperStack.ST.ST
(b:
LowStar.PrefixFreezableBuffer.lbuffer len
{LowStar.Monotonic.Buffer.frameOf b == r /\ LowStar.Monotonic.Buffer.freeable b}) | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperHeap.rid",
"LowStar.PrefixFreezableBuffer.u32",
"LowStar.PrefixFreezableBuffer.lbuffer",
"Prims.l_and",
"Prims.eq2",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"LowStar.Monotonic.Buffer.freeable",
"Prims.unit",
"LowStar.PrefixFreezableBuffer.update_frozen_until_alloc",
"Prims._assert",
"LowStar.Monotonic.Buffer.fresh_loc",
"LowStar.Monotonic.Buffer.loc_buffer",
"FStar.Endianness.le_to_n_zeros",
"FStar.Seq.Base.slice",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"FStar.UInt32.add",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Monotonic.Buffer.mmalloc",
"FStar.UInt8.__uint_to_t",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.lmbuffer"
] | [] | false | true | false | false | false | let malloc r len =
| let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in
E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h);
update_frozen_until_alloc b;
b | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.freeze | val freeze (b:buffer) (i:u32)
: Stack
unit
(requires fun h ->
live h b /\
U32.v i <= length b /\
U32.v i >= frozen_until (as_seq h b))
(ensures fun h0 _ h1 ->
(not (g_is_null b)) /\
modifies (loc_buffer b) h0 h1 /\
live h1 b /\
frozen_until (as_seq h1 b) == U32.v i /\
b `witnessed` frozen_until_at_least (U32.v i) /\
(forall (k:nat).{:pattern (Seq.index (as_seq h1 b) k)} //contents from [4, len) remain same
(4 <= k /\ k < length b) ==>
(Seq.index (as_seq h1 b) k == Seq.index (as_seq h0 b) k))) | val freeze (b:buffer) (i:u32)
: Stack
unit
(requires fun h ->
live h b /\
U32.v i <= length b /\
U32.v i >= frozen_until (as_seq h b))
(ensures fun h0 _ h1 ->
(not (g_is_null b)) /\
modifies (loc_buffer b) h0 h1 /\
live h1 b /\
frozen_until (as_seq h1 b) == U32.v i /\
b `witnessed` frozen_until_at_least (U32.v i) /\
(forall (k:nat).{:pattern (Seq.index (as_seq h1 b) k)} //contents from [4, len) remain same
(4 <= k /\ k < length b) ==>
(Seq.index (as_seq h1 b) k == Seq.index (as_seq h0 b) k))) | let freeze b i =
recall_p b (frozen_until_at_least 4);
FStar.Classical.forall_intro_2 le_pre_post_index;
LE.store32_le_i b 0ul i;
witness_p b (frozen_until_at_least (U32.v i)) | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 47,
"end_line": 131,
"start_col": 0,
"start_line": 127
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let upd b i v =
recall_p b (frozen_until_at_least 4);
upd b i v
(*
* This lemma handles the mismatch between the style of the spec
* in LE.store_pre and LE.store_post, and the preorder of PrefixFreezableBuffers
* Basically the sequence library is missing a lemma that eliminates
* equality on two slices to some equality on the base sequences
*)
let le_pre_post_index
(s1 s2:Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\
Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1))
(Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i:nat).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==>
(Seq.index s1 i == Seq.index s2 i)))
= assert (forall (s:Seq.seq u8).
Seq.length s >= 4 ==>
(forall (i:nat).
(i >= 4 /\ i < Seq.length s) ==>
Seq.index s i == Seq.index (Seq.slice s 4 (Seq.length s)) (i - 4))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: LowStar.PrefixFreezableBuffer.buffer -> i: LowStar.PrefixFreezableBuffer.u32
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.PrefixFreezableBuffer.buffer",
"LowStar.PrefixFreezableBuffer.u32",
"LowStar.Monotonic.Buffer.witness_p",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"LowStar.PrefixFreezableBuffer.frozen_until_at_least",
"FStar.UInt32.v",
"Prims.unit",
"LowStar.Endianness.store32_le_i",
"FStar.UInt32.__uint_to_t",
"FStar.Classical.forall_intro_2",
"FStar.Seq.Base.seq",
"Prims.l_imp",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.slice",
"Prims.l_Forall",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"LowStar.PrefixFreezableBuffer.le_pre_post_index",
"LowStar.Monotonic.Buffer.recall_p"
] | [] | false | true | false | false | false | let freeze b i =
| recall_p b (frozen_until_at_least 4);
FStar.Classical.forall_intro_2 le_pre_post_index;
LE.store32_le_i b 0ul i;
witness_p b (frozen_until_at_least (U32.v i)) | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.witness_slice | val witness_slice (b:buffer) (i j:u32) (snap:G.erased (Seq.seq u8))
: Stack
unit
(requires fun h -> slice_is i j snap (as_seq h b))
(ensures fun h0 _ h1 ->
h0 == h1 /\
b `witnessed` slice_is i j snap) | val witness_slice (b:buffer) (i j:u32) (snap:G.erased (Seq.seq u8))
: Stack
unit
(requires fun h -> slice_is i j snap (as_seq h b))
(ensures fun h0 _ h1 ->
h0 == h1 /\
b `witnessed` slice_is i j snap) | let witness_slice b i j snap =
witness_p b (slice_is i j snap) | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 33,
"end_line": 136,
"start_col": 0,
"start_line": 135
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let upd b i v =
recall_p b (frozen_until_at_least 4);
upd b i v
(*
* This lemma handles the mismatch between the style of the spec
* in LE.store_pre and LE.store_post, and the preorder of PrefixFreezableBuffers
* Basically the sequence library is missing a lemma that eliminates
* equality on two slices to some equality on the base sequences
*)
let le_pre_post_index
(s1 s2:Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\
Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1))
(Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i:nat).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==>
(Seq.index s1 i == Seq.index s2 i)))
= assert (forall (s:Seq.seq u8).
Seq.length s >= 4 ==>
(forall (i:nat).
(i >= 4 /\ i < Seq.length s) ==>
Seq.index s i == Seq.index (Seq.slice s 4 (Seq.length s)) (i - 4)))
let freeze b i =
recall_p b (frozen_until_at_least 4);
FStar.Classical.forall_intro_2 le_pre_post_index;
LE.store32_le_i b 0ul i;
witness_p b (frozen_until_at_least (U32.v i))
let frozen_until_st b = LE.load32_le_i b 0ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b: LowStar.PrefixFreezableBuffer.buffer ->
i: LowStar.PrefixFreezableBuffer.u32 ->
j: LowStar.PrefixFreezableBuffer.u32 ->
snap: FStar.Ghost.erased (FStar.Seq.Base.seq LowStar.PrefixFreezableBuffer.u8)
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.PrefixFreezableBuffer.buffer",
"LowStar.PrefixFreezableBuffer.u32",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.Monotonic.Buffer.witness_p",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"LowStar.PrefixFreezableBuffer.slice_is",
"Prims.unit"
] | [] | false | true | false | false | false | let witness_slice b i j snap =
| witness_p b (slice_is i j snap) | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.frozen_until_st | val frozen_until_st (b:buffer)
: Stack
u32
(requires fun h -> live h b)
(ensures fun h0 r h1 ->
h0 == h1 /\
U32.v r == frozen_until (as_seq h1 b)) | val frozen_until_st (b:buffer)
: Stack
u32
(requires fun h -> live h b)
(ensures fun h0 r h1 ->
h0 == h1 /\
U32.v r == frozen_until (as_seq h1 b)) | let frozen_until_st b = LE.load32_le_i b 0ul | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 133,
"start_col": 0,
"start_line": 133
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let upd b i v =
recall_p b (frozen_until_at_least 4);
upd b i v
(*
* This lemma handles the mismatch between the style of the spec
* in LE.store_pre and LE.store_post, and the preorder of PrefixFreezableBuffers
* Basically the sequence library is missing a lemma that eliminates
* equality on two slices to some equality on the base sequences
*)
let le_pre_post_index
(s1 s2:Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\
Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1))
(Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i:nat).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==>
(Seq.index s1 i == Seq.index s2 i)))
= assert (forall (s:Seq.seq u8).
Seq.length s >= 4 ==>
(forall (i:nat).
(i >= 4 /\ i < Seq.length s) ==>
Seq.index s i == Seq.index (Seq.slice s 4 (Seq.length s)) (i - 4)))
let freeze b i =
recall_p b (frozen_until_at_least 4);
FStar.Classical.forall_intro_2 le_pre_post_index;
LE.store32_le_i b 0ul i;
witness_p b (frozen_until_at_least (U32.v i)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: LowStar.PrefixFreezableBuffer.buffer
-> FStar.HyperStack.ST.Stack LowStar.PrefixFreezableBuffer.u32 | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.PrefixFreezableBuffer.buffer",
"LowStar.Endianness.load32_le_i",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"FStar.UInt32.__uint_to_t",
"LowStar.Endianness.u32",
"LowStar.PrefixFreezableBuffer.u32"
] | [] | false | true | false | false | false | let frozen_until_st b =
| LE.load32_le_i b 0ul | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.witness_frozen_until | val witness_frozen_until (b:buffer) (n:nat)
: Stack
unit
(requires fun h -> frozen_until_at_least n (as_seq h b))
(ensures fun h0 _ h1 ->
h0 == h1 /\
b `witnessed` frozen_until_at_least n) | val witness_frozen_until (b:buffer) (n:nat)
: Stack
unit
(requires fun h -> frozen_until_at_least n (as_seq h b))
(ensures fun h0 _ h1 ->
h0 == h1 /\
b `witnessed` frozen_until_at_least n) | let witness_frozen_until b n =
witness_p b (frozen_until_at_least n) | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 39,
"end_line": 142,
"start_col": 0,
"start_line": 141
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let upd b i v =
recall_p b (frozen_until_at_least 4);
upd b i v
(*
* This lemma handles the mismatch between the style of the spec
* in LE.store_pre and LE.store_post, and the preorder of PrefixFreezableBuffers
* Basically the sequence library is missing a lemma that eliminates
* equality on two slices to some equality on the base sequences
*)
let le_pre_post_index
(s1 s2:Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\
Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1))
(Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i:nat).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==>
(Seq.index s1 i == Seq.index s2 i)))
= assert (forall (s:Seq.seq u8).
Seq.length s >= 4 ==>
(forall (i:nat).
(i >= 4 /\ i < Seq.length s) ==>
Seq.index s i == Seq.index (Seq.slice s 4 (Seq.length s)) (i - 4)))
let freeze b i =
recall_p b (frozen_until_at_least 4);
FStar.Classical.forall_intro_2 le_pre_post_index;
LE.store32_le_i b 0ul i;
witness_p b (frozen_until_at_least (U32.v i))
let frozen_until_st b = LE.load32_le_i b 0ul
let witness_slice b i j snap =
witness_p b (slice_is i j snap)
let recall_slice b i j snap =
recall_p b (slice_is i j snap) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: LowStar.PrefixFreezableBuffer.buffer -> n: Prims.nat -> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.PrefixFreezableBuffer.buffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.witness_p",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"LowStar.PrefixFreezableBuffer.frozen_until_at_least",
"Prims.unit"
] | [] | false | true | false | false | false | let witness_frozen_until b n =
| witness_p b (frozen_until_at_least n) | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.recall_frozen_until_default | val recall_frozen_until_default (b:buffer)
: Stack
unit
(requires fun h -> recallable b \/ live h b)
(ensures fun h0 _ h1 ->
h0 == h1 /\
frozen_until_at_least 4 (as_seq h1 b)) | val recall_frozen_until_default (b:buffer)
: Stack
unit
(requires fun h -> recallable b \/ live h b)
(ensures fun h0 _ h1 ->
h0 == h1 /\
frozen_until_at_least 4 (as_seq h1 b)) | let recall_frozen_until_default b =
recall_p b (frozen_until_at_least 4) | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 148,
"start_col": 0,
"start_line": 147
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let upd b i v =
recall_p b (frozen_until_at_least 4);
upd b i v
(*
* This lemma handles the mismatch between the style of the spec
* in LE.store_pre and LE.store_post, and the preorder of PrefixFreezableBuffers
* Basically the sequence library is missing a lemma that eliminates
* equality on two slices to some equality on the base sequences
*)
let le_pre_post_index
(s1 s2:Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\
Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1))
(Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i:nat).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==>
(Seq.index s1 i == Seq.index s2 i)))
= assert (forall (s:Seq.seq u8).
Seq.length s >= 4 ==>
(forall (i:nat).
(i >= 4 /\ i < Seq.length s) ==>
Seq.index s i == Seq.index (Seq.slice s 4 (Seq.length s)) (i - 4)))
let freeze b i =
recall_p b (frozen_until_at_least 4);
FStar.Classical.forall_intro_2 le_pre_post_index;
LE.store32_le_i b 0ul i;
witness_p b (frozen_until_at_least (U32.v i))
let frozen_until_st b = LE.load32_le_i b 0ul
let witness_slice b i j snap =
witness_p b (slice_is i j snap)
let recall_slice b i j snap =
recall_p b (slice_is i j snap)
let witness_frozen_until b n =
witness_p b (frozen_until_at_least n)
let recall_frozen_until b n =
recall_p b (frozen_until_at_least n) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: LowStar.PrefixFreezableBuffer.buffer -> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.PrefixFreezableBuffer.buffer",
"LowStar.Monotonic.Buffer.recall_p",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"LowStar.PrefixFreezableBuffer.frozen_until_at_least",
"Prims.unit"
] | [] | false | true | false | false | false | let recall_frozen_until_default b =
| recall_p b (frozen_until_at_least 4) | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.recall_slice | val recall_slice (b:buffer) (i j:u32) (snap:G.erased (Seq.seq u8))
: Stack
unit
(requires fun h ->
(recallable b \/ live h b) /\
b `witnessed` slice_is i j snap)
(ensures fun h0 _ h1 ->
h0 == h1 /\
slice_is i j snap (as_seq h1 b)) | val recall_slice (b:buffer) (i j:u32) (snap:G.erased (Seq.seq u8))
: Stack
unit
(requires fun h ->
(recallable b \/ live h b) /\
b `witnessed` slice_is i j snap)
(ensures fun h0 _ h1 ->
h0 == h1 /\
slice_is i j snap (as_seq h1 b)) | let recall_slice b i j snap =
recall_p b (slice_is i j snap) | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 139,
"start_col": 0,
"start_line": 138
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let upd b i v =
recall_p b (frozen_until_at_least 4);
upd b i v
(*
* This lemma handles the mismatch between the style of the spec
* in LE.store_pre and LE.store_post, and the preorder of PrefixFreezableBuffers
* Basically the sequence library is missing a lemma that eliminates
* equality on two slices to some equality on the base sequences
*)
let le_pre_post_index
(s1 s2:Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\
Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1))
(Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i:nat).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==>
(Seq.index s1 i == Seq.index s2 i)))
= assert (forall (s:Seq.seq u8).
Seq.length s >= 4 ==>
(forall (i:nat).
(i >= 4 /\ i < Seq.length s) ==>
Seq.index s i == Seq.index (Seq.slice s 4 (Seq.length s)) (i - 4)))
let freeze b i =
recall_p b (frozen_until_at_least 4);
FStar.Classical.forall_intro_2 le_pre_post_index;
LE.store32_le_i b 0ul i;
witness_p b (frozen_until_at_least (U32.v i))
let frozen_until_st b = LE.load32_le_i b 0ul
let witness_slice b i j snap =
witness_p b (slice_is i j snap) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b: LowStar.PrefixFreezableBuffer.buffer ->
i: LowStar.PrefixFreezableBuffer.u32 ->
j: LowStar.PrefixFreezableBuffer.u32 ->
snap: FStar.Ghost.erased (FStar.Seq.Base.seq LowStar.PrefixFreezableBuffer.u8)
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.PrefixFreezableBuffer.buffer",
"LowStar.PrefixFreezableBuffer.u32",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.Monotonic.Buffer.recall_p",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"LowStar.PrefixFreezableBuffer.slice_is",
"Prims.unit"
] | [] | false | true | false | false | false | let recall_slice b i j snap =
| recall_p b (slice_is i j snap) | false |
LowStar.PrefixFreezableBuffer.fst | LowStar.PrefixFreezableBuffer.recall_frozen_until | val recall_frozen_until (b:buffer) (n:nat)
: Stack
unit
(requires fun h ->
(recallable b \/ live h b) /\
b `witnessed` frozen_until_at_least n)
(ensures fun h0 _ h1 ->
h0 == h1 /\
frozen_until_at_least n (as_seq h1 b)) | val recall_frozen_until (b:buffer) (n:nat)
: Stack
unit
(requires fun h ->
(recallable b \/ live h b) /\
b `witnessed` frozen_until_at_least n)
(ensures fun h0 _ h1 ->
h0 == h1 /\
frozen_until_at_least n (as_seq h1 b)) | let recall_frozen_until b n =
recall_p b (frozen_until_at_least n) | {
"file_name": "ulib/LowStar.PrefixFreezableBuffer.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 145,
"start_col": 0,
"start_line": 144
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module LowStar.PrefixFreezableBuffer
open FStar.HyperStack.ST
include LowStar.Monotonic.Buffer
module P = FStar.Preorder
module G = FStar.Ghost
module U8 = FStar.UInt8
module U32 = FStar.UInt32
module Seq = FStar.Seq
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module E = FStar.Endianness
module LE = LowStar.Endianness
(*
* Implementation for LowStar.PrefixfreezableBuffer
*)
#set-options "--max_fuel 0 --max_ifuel 0"
let le_to_n s = E.le_to_n s
let prefix_freezable_preorder = pre
let prefix_freezable_preorder_elim _ _ = ()
private let update_frozen_until_alloc
(b:mbuffer u8 prefix_freezable_preorder prefix_freezable_preorder)
: Stack
unit
(requires fun h ->
live h b /\
length b >= 4 /\
frozen_until (as_seq h b) == 0)
(ensures fun h0 _ h1 ->
live h1 b /\
modifies (loc_buffer b) h0 h1 /\
frozen_until (as_seq h1 b) == 4 /\
witnessed b (frozen_until_at_least 4))
= LE.store32_le_i b 0ul 4ul;
witness_p b (frozen_until_at_least 4)
let gcmalloc r len =
let h0 = ST.get () in
let b = mgcmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let malloc r len =
let h0 = ST.get () in
let b = mmalloc #_ #prefix_freezable_preorder r 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let alloca len =
let h0 = ST.get () in
let b = malloca #_ #prefix_freezable_preorder 0uy (U32.add len 4ul) in
let h = ST.get () in E.le_to_n_zeros (Seq.slice (as_seq h b) 0 4);
assert (fresh_loc (loc_buffer b) h0 h); //TODO: necessary for firing modifies_remove_new_locs lemma?
update_frozen_until_alloc b;
b
let upd b i v =
recall_p b (frozen_until_at_least 4);
upd b i v
(*
* This lemma handles the mismatch between the style of the spec
* in LE.store_pre and LE.store_post, and the preorder of PrefixFreezableBuffers
* Basically the sequence library is missing a lemma that eliminates
* equality on two slices to some equality on the base sequences
*)
let le_pre_post_index
(s1 s2:Seq.seq u8)
: Lemma
(ensures
(Seq.length s1 == Seq.length s2 /\
Seq.length s1 >= 4 /\
Seq.equal (Seq.slice s1 0 0) (Seq.slice s2 0 0) /\
Seq.equal (Seq.slice s1 4 (Seq.length s1))
(Seq.slice s2 4 (Seq.length s2))) ==>
(forall (i:nat).{:pattern (Seq.index s1 i); (Seq.index s2 i)}
(i >= 4 /\ i < Seq.length s1) ==>
(Seq.index s1 i == Seq.index s2 i)))
= assert (forall (s:Seq.seq u8).
Seq.length s >= 4 ==>
(forall (i:nat).
(i >= 4 /\ i < Seq.length s) ==>
Seq.index s i == Seq.index (Seq.slice s 4 (Seq.length s)) (i - 4)))
let freeze b i =
recall_p b (frozen_until_at_least 4);
FStar.Classical.forall_intro_2 le_pre_post_index;
LE.store32_le_i b 0ul i;
witness_p b (frozen_until_at_least (U32.v i))
let frozen_until_st b = LE.load32_le_i b 0ul
let witness_slice b i j snap =
witness_p b (slice_is i j snap)
let recall_slice b i j snap =
recall_p b (slice_is i j snap)
let witness_frozen_until b n =
witness_p b (frozen_until_at_least n) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Endianness.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowStar.PrefixFreezableBuffer.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: LowStar.PrefixFreezableBuffer.buffer -> n: Prims.nat -> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"LowStar.PrefixFreezableBuffer.buffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.recall_p",
"LowStar.PrefixFreezableBuffer.u8",
"LowStar.PrefixFreezableBuffer.prefix_freezable_preorder",
"LowStar.PrefixFreezableBuffer.frozen_until_at_least",
"Prims.unit"
] | [] | false | true | false | false | false | let recall_frozen_until b n =
| recall_p b (frozen_until_at_least n) | false |
LowParse.SLow.VLGen.fst | LowParse.SLow.VLGen.serialize32_bounded_vlgen_precond | val serialize32_bounded_vlgen_precond (min: nat) (max: nat{min <= max}) (sk k: parser_kind)
: GTot bool | val serialize32_bounded_vlgen_precond (min: nat) (max: nat{min <= max}) (sk k: parser_kind)
: GTot bool | let serialize32_bounded_vlgen_precond
(min: nat)
(max: nat { min <= max } )
(sk: parser_kind)
(k: parser_kind)
: GTot bool
= match sk.parser_kind_high with
| None -> false
| Some kmax ->
let max' = match k.parser_kind_high with
| None -> max
| Some km -> if km < max then km else max
in
kmax + max' < 4294967296 | {
"file_name": "src/lowparse/LowParse.SLow.VLGen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 28,
"end_line": 70,
"start_col": 0,
"start_line": 57
} | module LowParse.SLow.VLGen
include LowParse.SLow.Combinators
include LowParse.SLow.FLData
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module B32 = LowParse.Bytes32
inline_for_extraction
let parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t { U32.v min == vmin } )
(vmax: der_length_t)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s))
= fun (input: bytes32) -> ((
[@inline_let]
let _ = parse_bounded_vlgen_unfold_aux (U32.v min) (U32.v max) pk s (B32.reveal input) in
match pk32 input with
| None -> None
| Some (sz, consumed) ->
let input' = B32.slice input consumed (B32.len input) in
match parse32_fldata_strong s p32 (U32.v sz) sz input' with
| None -> None
| Some (x, consumed') -> Some ((x <: parse_bounded_vldata_strong_t (U32.v min) (U32.v max) s), consumed `U32.add` consumed')
) <: (res: _ { parser32_correct (parse_bounded_vlgen (U32.v min) (U32.v max) pk s) input res } ))
inline_for_extraction
let parse32_vlgen
(vmin: nat)
(min: U32.t { U32.v min == vmin } )
(vmax: nat)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p { parse_vlgen_precond (U32.v min) (U32.v max) k } )
(p32: parser32 p)
: Tot (parser32 (parse_vlgen (vmin) (vmax) pk s))
= parse32_synth'
_
(synth_vlgen (U32.v min) (U32.v max) s)
(parse32_bounded_vlgen vmin min vmax max pk32 s p32)
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.SLow.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.VLGen.fst"
} | [
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max} ->
sk: LowParse.Spec.Base.parser_kind ->
k: LowParse.Spec.Base.parser_kind
-> Prims.GTot Prims.bool | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.int",
"Prims.bool"
] | [] | false | false | false | false | false | let serialize32_bounded_vlgen_precond (min: nat) (max: nat{min <= max}) (sk k: parser_kind)
: GTot bool =
| match sk.parser_kind_high with
| None -> false
| Some kmax ->
let max' =
match k.parser_kind_high with
| None -> max
| Some km -> if km < max then km else max
in
kmax + max' < 4294967296 | false |
LowParse.SLow.VLGen.fst | LowParse.SLow.VLGen.serialize32_vlgen | val serialize32_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32:
partial_serializer32 s
{parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k})
: Tot (serializer32 (serialize_vlgen min max ssk s)) | val serialize32_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32:
partial_serializer32 s
{parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k})
: Tot (serializer32 (serialize_vlgen min max ssk s)) | let serialize32_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s { parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k } )
: Tot (serializer32 (serialize_vlgen min max ssk s))
= serialize32_synth'
_
(synth_vlgen min max s)
_
(serialize32_bounded_vlgen min max ssk32 s32)
(synth_vlgen_recip min max s)
() | {
"file_name": "src/lowparse/LowParse.SLow.VLGen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 114,
"start_col": 0,
"start_line": 95
} | module LowParse.SLow.VLGen
include LowParse.SLow.Combinators
include LowParse.SLow.FLData
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module B32 = LowParse.Bytes32
inline_for_extraction
let parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t { U32.v min == vmin } )
(vmax: der_length_t)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s))
= fun (input: bytes32) -> ((
[@inline_let]
let _ = parse_bounded_vlgen_unfold_aux (U32.v min) (U32.v max) pk s (B32.reveal input) in
match pk32 input with
| None -> None
| Some (sz, consumed) ->
let input' = B32.slice input consumed (B32.len input) in
match parse32_fldata_strong s p32 (U32.v sz) sz input' with
| None -> None
| Some (x, consumed') -> Some ((x <: parse_bounded_vldata_strong_t (U32.v min) (U32.v max) s), consumed `U32.add` consumed')
) <: (res: _ { parser32_correct (parse_bounded_vlgen (U32.v min) (U32.v max) pk s) input res } ))
inline_for_extraction
let parse32_vlgen
(vmin: nat)
(min: U32.t { U32.v min == vmin } )
(vmax: nat)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p { parse_vlgen_precond (U32.v min) (U32.v max) k } )
(p32: parser32 p)
: Tot (parser32 (parse_vlgen (vmin) (vmax) pk s))
= parse32_synth'
_
(synth_vlgen (U32.v min) (U32.v max) s)
(parse32_bounded_vlgen vmin min vmax max pk32 s p32)
()
let serialize32_bounded_vlgen_precond
(min: nat)
(max: nat { min <= max } )
(sk: parser_kind)
(k: parser_kind)
: GTot bool
= match sk.parser_kind_high with
| None -> false
| Some kmax ->
let max' = match k.parser_kind_high with
| None -> max
| Some km -> if km < max then km else max
in
kmax + max' < 4294967296
inline_for_extraction
let serialize32_bounded_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s { serialize32_bounded_vlgen_precond min max sk k } )
: Tot (serializer32 (serialize_bounded_vlgen min max ssk s))
= fun (input: parse_bounded_vldata_strong_t min max s) -> ((
[@inline_let]
let _ = serialize_bounded_vlgen_unfold min max ssk s input in
let sp = s32 input in
let len = B32.len sp in
ssk32 len `B32.append` sp
) <: (res: _ { serializer32_correct (serialize_bounded_vlgen min max ssk s) input res } )) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.SLow.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.VLGen.fst"
} | [
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
ssk32:
LowParse.SLow.Base.serializer32 ssk
{ Mkparser_kind'?.parser_kind_subkind sk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
s32:
LowParse.SLow.Base.partial_serializer32 s
{ LowParse.Spec.VLGen.parse_vlgen_precond min max k /\
LowParse.SLow.VLGen.serialize32_bounded_vlgen_precond min max sk k }
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.VLGen.serialize_vlgen min max ssk s) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.serializer32",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.SLow.Base.partial_serializer32",
"LowParse.Spec.VLGen.parse_vlgen_precond",
"LowParse.SLow.VLGen.serialize32_bounded_vlgen_precond",
"LowParse.SLow.Combinators.serialize32_synth'",
"LowParse.Spec.VLGen.parse_bounded_vlgen_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"LowParse.Spec.VLGen.parse_bounded_vlgen",
"LowParse.Spec.VLGen.synth_vlgen",
"LowParse.Spec.VLGen.serialize_bounded_vlgen",
"LowParse.SLow.VLGen.serialize32_bounded_vlgen",
"LowParse.Spec.VLGen.synth_vlgen_recip",
"LowParse.Spec.VLGen.parse_vlgen",
"LowParse.Spec.VLGen.serialize_vlgen"
] | [] | false | false | false | false | false | let serialize32_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32:
partial_serializer32 s
{parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k})
: Tot (serializer32 (serialize_vlgen min max ssk s)) =
| serialize32_synth' _
(synth_vlgen min max s)
_
(serialize32_bounded_vlgen min max ssk32 s32)
(synth_vlgen_recip min max s)
() | false |
LowParse.SLow.VLGen.fst | LowParse.SLow.VLGen.parse32_vlgen | val parse32_vlgen
(vmin: nat)
(min: U32.t{U32.v min == vmin})
(vmax: nat)
(max: U32.t{U32.v max == vmax /\ U32.v min <= U32.v max})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p {parse_vlgen_precond (U32.v min) (U32.v max) k})
(p32: parser32 p)
: Tot (parser32 (parse_vlgen (vmin) (vmax) pk s)) | val parse32_vlgen
(vmin: nat)
(min: U32.t{U32.v min == vmin})
(vmax: nat)
(max: U32.t{U32.v max == vmax /\ U32.v min <= U32.v max})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p {parse_vlgen_precond (U32.v min) (U32.v max) k})
(p32: parser32 p)
: Tot (parser32 (parse_vlgen (vmin) (vmax) pk s)) | let parse32_vlgen
(vmin: nat)
(min: U32.t { U32.v min == vmin } )
(vmax: nat)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p { parse_vlgen_precond (U32.v min) (U32.v max) k } )
(p32: parser32 p)
: Tot (parser32 (parse_vlgen (vmin) (vmax) pk s))
= parse32_synth'
_
(synth_vlgen (U32.v min) (U32.v max) s)
(parse32_bounded_vlgen vmin min vmax max pk32 s p32)
() | {
"file_name": "src/lowparse/LowParse.SLow.VLGen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 55,
"start_col": 0,
"start_line": 37
} | module LowParse.SLow.VLGen
include LowParse.SLow.Combinators
include LowParse.SLow.FLData
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module B32 = LowParse.Bytes32
inline_for_extraction
let parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t { U32.v min == vmin } )
(vmax: der_length_t)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s))
= fun (input: bytes32) -> ((
[@inline_let]
let _ = parse_bounded_vlgen_unfold_aux (U32.v min) (U32.v max) pk s (B32.reveal input) in
match pk32 input with
| None -> None
| Some (sz, consumed) ->
let input' = B32.slice input consumed (B32.len input) in
match parse32_fldata_strong s p32 (U32.v sz) sz input' with
| None -> None
| Some (x, consumed') -> Some ((x <: parse_bounded_vldata_strong_t (U32.v min) (U32.v max) s), consumed `U32.add` consumed')
) <: (res: _ { parser32_correct (parse_bounded_vlgen (U32.v min) (U32.v max) pk s) input res } )) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.SLow.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.VLGen.fst"
} | [
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
vmin: Prims.nat ->
min: FStar.UInt32.t{FStar.UInt32.v min == vmin} ->
vmax: Prims.nat ->
max: FStar.UInt32.t{FStar.UInt32.v max == vmax /\ FStar.UInt32.v min <= FStar.UInt32.v max} ->
pk32: LowParse.SLow.Base.parser32 pk ->
s:
LowParse.Spec.Base.serializer p
{LowParse.Spec.VLGen.parse_vlgen_precond (FStar.UInt32.v min) (FStar.UInt32.v max) k} ->
p32: LowParse.SLow.Base.parser32 p
-> LowParse.SLow.Base.parser32 (LowParse.Spec.VLGen.parse_vlgen vmin vmax pk s) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.VLGen.parse_vlgen_precond",
"LowParse.SLow.Combinators.parse32_synth'",
"LowParse.Spec.VLGen.parse_bounded_vlgen_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"LowParse.Spec.VLGen.parse_bounded_vlgen",
"LowParse.Spec.VLGen.synth_vlgen",
"LowParse.SLow.VLGen.parse32_bounded_vlgen",
"LowParse.Spec.VLGen.parse_vlgen"
] | [] | false | false | false | false | false | let parse32_vlgen
(vmin: nat)
(min: U32.t{U32.v min == vmin})
(vmax: nat)
(max: U32.t{U32.v max == vmax /\ U32.v min <= U32.v max})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p {parse_vlgen_precond (U32.v min) (U32.v max) k})
(p32: parser32 p)
: Tot (parser32 (parse_vlgen (vmin) (vmax) pk s)) =
| parse32_synth' _
(synth_vlgen (U32.v min) (U32.v max) s)
(parse32_bounded_vlgen vmin min vmax max pk32 s p32)
() | false |
LowParse.SLow.VLGen.fst | LowParse.SLow.VLGen.size32_vlgen | val size32_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: size32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32:
size32 s {parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k}
)
: Tot (size32 (serialize_vlgen min max ssk s)) | val size32_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: size32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32:
size32 s {parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k}
)
: Tot (size32 (serialize_vlgen min max ssk s)) | let size32_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: size32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s { parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k } )
: Tot (size32 (serialize_vlgen min max ssk s))
= size32_synth'
_
(synth_vlgen min max s)
_
(size32_bounded_vlgen min max ssk32 s32)
(synth_vlgen_recip min max s)
() | {
"file_name": "src/lowparse/LowParse.SLow.VLGen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 157,
"start_col": 0,
"start_line": 138
} | module LowParse.SLow.VLGen
include LowParse.SLow.Combinators
include LowParse.SLow.FLData
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module B32 = LowParse.Bytes32
inline_for_extraction
let parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t { U32.v min == vmin } )
(vmax: der_length_t)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s))
= fun (input: bytes32) -> ((
[@inline_let]
let _ = parse_bounded_vlgen_unfold_aux (U32.v min) (U32.v max) pk s (B32.reveal input) in
match pk32 input with
| None -> None
| Some (sz, consumed) ->
let input' = B32.slice input consumed (B32.len input) in
match parse32_fldata_strong s p32 (U32.v sz) sz input' with
| None -> None
| Some (x, consumed') -> Some ((x <: parse_bounded_vldata_strong_t (U32.v min) (U32.v max) s), consumed `U32.add` consumed')
) <: (res: _ { parser32_correct (parse_bounded_vlgen (U32.v min) (U32.v max) pk s) input res } ))
inline_for_extraction
let parse32_vlgen
(vmin: nat)
(min: U32.t { U32.v min == vmin } )
(vmax: nat)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p { parse_vlgen_precond (U32.v min) (U32.v max) k } )
(p32: parser32 p)
: Tot (parser32 (parse_vlgen (vmin) (vmax) pk s))
= parse32_synth'
_
(synth_vlgen (U32.v min) (U32.v max) s)
(parse32_bounded_vlgen vmin min vmax max pk32 s p32)
()
let serialize32_bounded_vlgen_precond
(min: nat)
(max: nat { min <= max } )
(sk: parser_kind)
(k: parser_kind)
: GTot bool
= match sk.parser_kind_high with
| None -> false
| Some kmax ->
let max' = match k.parser_kind_high with
| None -> max
| Some km -> if km < max then km else max
in
kmax + max' < 4294967296
inline_for_extraction
let serialize32_bounded_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s { serialize32_bounded_vlgen_precond min max sk k } )
: Tot (serializer32 (serialize_bounded_vlgen min max ssk s))
= fun (input: parse_bounded_vldata_strong_t min max s) -> ((
[@inline_let]
let _ = serialize_bounded_vlgen_unfold min max ssk s input in
let sp = s32 input in
let len = B32.len sp in
ssk32 len `B32.append` sp
) <: (res: _ { serializer32_correct (serialize_bounded_vlgen min max ssk s) input res } ))
inline_for_extraction
let serialize32_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s { parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k } )
: Tot (serializer32 (serialize_vlgen min max ssk s))
= serialize32_synth'
_
(synth_vlgen min max s)
_
(serialize32_bounded_vlgen min max ssk32 s32)
(synth_vlgen_recip min max s)
()
inline_for_extraction
let size32_bounded_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: size32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s { serialize32_bounded_vlgen_precond min max sk k } )
: Tot (size32 (serialize_bounded_vlgen min max ssk s))
= fun (input: parse_bounded_vldata_strong_t min max s) -> ((
[@inline_let]
let _ = serialize_bounded_vlgen_unfold min max ssk s input in
let sp = s32 input in
ssk32 sp `U32.add` sp
) <: (res: _ { size32_postcond (serialize_bounded_vlgen min max ssk s) input res } )) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.SLow.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.VLGen.fst"
} | [
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
ssk32:
LowParse.SLow.Base.size32 ssk
{ Mkparser_kind'?.parser_kind_subkind sk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
s32:
LowParse.SLow.Base.size32 s
{ LowParse.Spec.VLGen.parse_vlgen_precond min max k /\
LowParse.SLow.VLGen.serialize32_bounded_vlgen_precond min max sk k }
-> LowParse.SLow.Base.size32 (LowParse.Spec.VLGen.serialize_vlgen min max ssk s) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.size32",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.Spec.VLGen.parse_vlgen_precond",
"LowParse.SLow.VLGen.serialize32_bounded_vlgen_precond",
"LowParse.SLow.Combinators.size32_synth'",
"LowParse.Spec.VLGen.parse_bounded_vlgen_kind",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"LowParse.Spec.VLGen.parse_bounded_vlgen",
"LowParse.Spec.VLGen.synth_vlgen",
"LowParse.Spec.VLGen.serialize_bounded_vlgen",
"LowParse.SLow.VLGen.size32_bounded_vlgen",
"LowParse.Spec.VLGen.synth_vlgen_recip",
"LowParse.Spec.VLGen.parse_vlgen",
"LowParse.Spec.VLGen.serialize_vlgen"
] | [] | false | false | false | false | false | let size32_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: size32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32:
size32 s {parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k}
)
: Tot (size32 (serialize_vlgen min max ssk s)) =
| size32_synth' _
(synth_vlgen min max s)
_
(size32_bounded_vlgen min max ssk32 s32)
(synth_vlgen_recip min max s)
() | false |
LowParse.SLow.VLGen.fst | LowParse.SLow.VLGen.size32_bounded_vlgen | val size32_bounded_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: size32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s {serialize32_bounded_vlgen_precond min max sk k})
: Tot (size32 (serialize_bounded_vlgen min max ssk s)) | val size32_bounded_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: size32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s {serialize32_bounded_vlgen_precond min max sk k})
: Tot (size32 (serialize_bounded_vlgen min max ssk s)) | let size32_bounded_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: size32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s { serialize32_bounded_vlgen_precond min max sk k } )
: Tot (size32 (serialize_bounded_vlgen min max ssk s))
= fun (input: parse_bounded_vldata_strong_t min max s) -> ((
[@inline_let]
let _ = serialize_bounded_vlgen_unfold min max ssk s input in
let sp = s32 input in
ssk32 sp `U32.add` sp
) <: (res: _ { size32_postcond (serialize_bounded_vlgen min max ssk s) input res } )) | {
"file_name": "src/lowparse/LowParse.SLow.VLGen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 87,
"end_line": 135,
"start_col": 0,
"start_line": 117
} | module LowParse.SLow.VLGen
include LowParse.SLow.Combinators
include LowParse.SLow.FLData
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module B32 = LowParse.Bytes32
inline_for_extraction
let parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t { U32.v min == vmin } )
(vmax: der_length_t)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s))
= fun (input: bytes32) -> ((
[@inline_let]
let _ = parse_bounded_vlgen_unfold_aux (U32.v min) (U32.v max) pk s (B32.reveal input) in
match pk32 input with
| None -> None
| Some (sz, consumed) ->
let input' = B32.slice input consumed (B32.len input) in
match parse32_fldata_strong s p32 (U32.v sz) sz input' with
| None -> None
| Some (x, consumed') -> Some ((x <: parse_bounded_vldata_strong_t (U32.v min) (U32.v max) s), consumed `U32.add` consumed')
) <: (res: _ { parser32_correct (parse_bounded_vlgen (U32.v min) (U32.v max) pk s) input res } ))
inline_for_extraction
let parse32_vlgen
(vmin: nat)
(min: U32.t { U32.v min == vmin } )
(vmax: nat)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p { parse_vlgen_precond (U32.v min) (U32.v max) k } )
(p32: parser32 p)
: Tot (parser32 (parse_vlgen (vmin) (vmax) pk s))
= parse32_synth'
_
(synth_vlgen (U32.v min) (U32.v max) s)
(parse32_bounded_vlgen vmin min vmax max pk32 s p32)
()
let serialize32_bounded_vlgen_precond
(min: nat)
(max: nat { min <= max } )
(sk: parser_kind)
(k: parser_kind)
: GTot bool
= match sk.parser_kind_high with
| None -> false
| Some kmax ->
let max' = match k.parser_kind_high with
| None -> max
| Some km -> if km < max then km else max
in
kmax + max' < 4294967296
inline_for_extraction
let serialize32_bounded_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s { serialize32_bounded_vlgen_precond min max sk k } )
: Tot (serializer32 (serialize_bounded_vlgen min max ssk s))
= fun (input: parse_bounded_vldata_strong_t min max s) -> ((
[@inline_let]
let _ = serialize_bounded_vlgen_unfold min max ssk s input in
let sp = s32 input in
let len = B32.len sp in
ssk32 len `B32.append` sp
) <: (res: _ { serializer32_correct (serialize_bounded_vlgen min max ssk s) input res } ))
inline_for_extraction
let serialize32_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s { parse_vlgen_precond min max k /\ serialize32_bounded_vlgen_precond min max sk k } )
: Tot (serializer32 (serialize_vlgen min max ssk s))
= serialize32_synth'
_
(synth_vlgen min max s)
_
(serialize32_bounded_vlgen min max ssk32 s32)
(synth_vlgen_recip min max s)
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.SLow.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.VLGen.fst"
} | [
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
ssk32:
LowParse.SLow.Base.size32 ssk
{ Mkparser_kind'?.parser_kind_subkind sk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
s32:
LowParse.SLow.Base.size32 s
{LowParse.SLow.VLGen.serialize32_bounded_vlgen_precond min max sk k}
-> LowParse.SLow.Base.size32 (LowParse.Spec.VLGen.serialize_bounded_vlgen min max ssk s) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.size32",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.SLow.VLGen.serialize32_bounded_vlgen_precond",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"FStar.UInt32.add",
"FStar.UInt32.t",
"LowParse.SLow.Base.size32_postcond",
"Prims.unit",
"LowParse.Spec.VLGen.serialize_bounded_vlgen_unfold",
"LowParse.Spec.VLGen.parse_bounded_vlgen_kind",
"LowParse.Spec.VLGen.parse_bounded_vlgen",
"LowParse.Spec.VLGen.serialize_bounded_vlgen"
] | [] | false | false | false | false | false | let size32_bounded_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: size32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: size32 s {serialize32_bounded_vlgen_precond min max sk k})
: Tot (size32 (serialize_bounded_vlgen min max ssk s)) =
| fun (input: parse_bounded_vldata_strong_t min max s) ->
(([@@ inline_let ]let _ = serialize_bounded_vlgen_unfold min max ssk s input in
let sp = s32 input in
(ssk32 sp) `U32.add` sp)
<:
(res: _{size32_postcond (serialize_bounded_vlgen min max ssk s) input res})) | false |
LowParse.SLow.VLGen.fst | LowParse.SLow.VLGen.serialize32_bounded_vlgen | val serialize32_bounded_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s {serialize32_bounded_vlgen_precond min max sk k})
: Tot (serializer32 (serialize_bounded_vlgen min max ssk s)) | val serialize32_bounded_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s {serialize32_bounded_vlgen_precond min max sk k})
: Tot (serializer32 (serialize_bounded_vlgen min max ssk s)) | let serialize32_bounded_vlgen
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk { sk.parser_kind_subkind == Some ParserStrong } )
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s { serialize32_bounded_vlgen_precond min max sk k } )
: Tot (serializer32 (serialize_bounded_vlgen min max ssk s))
= fun (input: parse_bounded_vldata_strong_t min max s) -> ((
[@inline_let]
let _ = serialize_bounded_vlgen_unfold min max ssk s input in
let sp = s32 input in
let len = B32.len sp in
ssk32 len `B32.append` sp
) <: (res: _ { serializer32_correct (serialize_bounded_vlgen min max ssk s) input res } )) | {
"file_name": "src/lowparse/LowParse.SLow.VLGen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 92,
"end_line": 92,
"start_col": 0,
"start_line": 73
} | module LowParse.SLow.VLGen
include LowParse.SLow.Combinators
include LowParse.SLow.FLData
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module B32 = LowParse.Bytes32
inline_for_extraction
let parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t { U32.v min == vmin } )
(vmax: der_length_t)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s))
= fun (input: bytes32) -> ((
[@inline_let]
let _ = parse_bounded_vlgen_unfold_aux (U32.v min) (U32.v max) pk s (B32.reveal input) in
match pk32 input with
| None -> None
| Some (sz, consumed) ->
let input' = B32.slice input consumed (B32.len input) in
match parse32_fldata_strong s p32 (U32.v sz) sz input' with
| None -> None
| Some (x, consumed') -> Some ((x <: parse_bounded_vldata_strong_t (U32.v min) (U32.v max) s), consumed `U32.add` consumed')
) <: (res: _ { parser32_correct (parse_bounded_vlgen (U32.v min) (U32.v max) pk s) input res } ))
inline_for_extraction
let parse32_vlgen
(vmin: nat)
(min: U32.t { U32.v min == vmin } )
(vmax: nat)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p { parse_vlgen_precond (U32.v min) (U32.v max) k } )
(p32: parser32 p)
: Tot (parser32 (parse_vlgen (vmin) (vmax) pk s))
= parse32_synth'
_
(synth_vlgen (U32.v min) (U32.v max) s)
(parse32_bounded_vlgen vmin min vmax max pk32 s p32)
()
let serialize32_bounded_vlgen_precond
(min: nat)
(max: nat { min <= max } )
(sk: parser_kind)
(k: parser_kind)
: GTot bool
= match sk.parser_kind_high with
| None -> false
| Some kmax ->
let max' = match k.parser_kind_high with
| None -> max
| Some km -> if km < max then km else max
in
kmax + max' < 4294967296 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.SLow.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.VLGen.fst"
} | [
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
ssk32:
LowParse.SLow.Base.serializer32 ssk
{ Mkparser_kind'?.parser_kind_subkind sk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
s32:
LowParse.SLow.Base.partial_serializer32 s
{LowParse.SLow.VLGen.serialize32_bounded_vlgen_precond min max sk k}
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.VLGen.serialize_bounded_vlgen min max ssk s) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.serializer32",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.SLow.Base.partial_serializer32",
"LowParse.SLow.VLGen.serialize32_bounded_vlgen_precond",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"FStar.Bytes.append",
"FStar.UInt32.t",
"FStar.Bytes.len",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"Prims.unit",
"LowParse.Spec.VLGen.serialize_bounded_vlgen_unfold",
"LowParse.Spec.VLGen.parse_bounded_vlgen_kind",
"LowParse.Spec.VLGen.parse_bounded_vlgen",
"LowParse.Spec.VLGen.serialize_bounded_vlgen"
] | [] | false | false | false | false | false | let serialize32_bounded_vlgen
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 min max))
(#ssk: serializer pk)
(ssk32: serializer32 ssk {sk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s {serialize32_bounded_vlgen_precond min max sk k})
: Tot (serializer32 (serialize_bounded_vlgen min max ssk s)) =
| fun (input: parse_bounded_vldata_strong_t min max s) ->
(([@@ inline_let ]let _ = serialize_bounded_vlgen_unfold min max ssk s input in
let sp = s32 input in
let len = B32.len sp in
(ssk32 len) `B32.append` sp)
<:
(res: _{serializer32_correct (serialize_bounded_vlgen min max ssk s) input res})) | false |
LowParse.SLow.VLGen.fst | LowParse.SLow.VLGen.parse32_bounded_vlgen | val parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t{U32.v min == vmin})
(vmax: der_length_t)
(max: U32.t{U32.v max == vmax /\ U32.v min <= U32.v max})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s)) | val parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t{U32.v min == vmin})
(vmax: der_length_t)
(max: U32.t{U32.v max == vmax /\ U32.v min <= U32.v max})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s)) | let parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t { U32.v min == vmin } )
(vmax: der_length_t)
(max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } )
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s))
= fun (input: bytes32) -> ((
[@inline_let]
let _ = parse_bounded_vlgen_unfold_aux (U32.v min) (U32.v max) pk s (B32.reveal input) in
match pk32 input with
| None -> None
| Some (sz, consumed) ->
let input' = B32.slice input consumed (B32.len input) in
match parse32_fldata_strong s p32 (U32.v sz) sz input' with
| None -> None
| Some (x, consumed') -> Some ((x <: parse_bounded_vldata_strong_t (U32.v min) (U32.v max) s), consumed `U32.add` consumed')
) <: (res: _ { parser32_correct (parse_bounded_vlgen (U32.v min) (U32.v max) pk s) input res } )) | {
"file_name": "src/lowparse/LowParse.SLow.VLGen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 99,
"end_line": 34,
"start_col": 0,
"start_line": 10
} | module LowParse.SLow.VLGen
include LowParse.SLow.Combinators
include LowParse.SLow.FLData
include LowParse.Spec.VLGen
module U32 = FStar.UInt32
module B32 = LowParse.Bytes32 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.VLGen.fst.checked",
"LowParse.SLow.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.VLGen.fst"
} | [
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VLGen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
vmin: LowParse.Spec.DER.der_length_t ->
min: FStar.UInt32.t{FStar.UInt32.v min == vmin} ->
vmax: LowParse.Spec.DER.der_length_t ->
max: FStar.UInt32.t{FStar.UInt32.v max == vmax /\ FStar.UInt32.v min <= FStar.UInt32.v max} ->
pk32: LowParse.SLow.Base.parser32 pk ->
s: LowParse.Spec.Base.serializer p ->
p32: LowParse.SLow.Base.parser32 p
-> LowParse.SLow.Base.parser32 (LowParse.Spec.VLGen.parse_bounded_vlgen vmin vmax pk s) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.DER.der_length_t",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.DER.der_length_max",
"FStar.UInt32.v",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.bytes32",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.VLData.parse_bounded_vldata_strong_t",
"LowParse.SLow.FLData.parse32_fldata_strong",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.UInt32.add",
"FStar.Pervasives.Native.option",
"LowParse.SLow.Base.parser32_correct",
"LowParse.Spec.VLGen.parse_bounded_vlgen_kind",
"LowParse.Spec.VLGen.parse_bounded_vlgen",
"FStar.Bytes.bytes",
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"FStar.Bytes.reveal",
"FStar.Seq.Base.slice",
"FStar.Bytes.len",
"FStar.Bytes.slice",
"Prims.unit",
"LowParse.Spec.VLGen.parse_bounded_vlgen_unfold_aux"
] | [] | false | false | false | false | false | let parse32_bounded_vlgen
(vmin: der_length_t)
(min: U32.t{U32.v min == vmin})
(vmax: der_length_t)
(max: U32.t{U32.v max == vmax /\ U32.v min <= U32.v max})
(#sk: parser_kind)
(#pk: parser sk (bounded_int32 (U32.v min) (U32.v max)))
(pk32: parser32 pk)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
: Tot (parser32 (parse_bounded_vlgen (vmin) (vmax) pk s)) =
| fun (input: bytes32) ->
(([@@ inline_let ]let _ =
parse_bounded_vlgen_unfold_aux (U32.v min) (U32.v max) pk s (B32.reveal input)
in
match pk32 input with
| None -> None
| Some (sz, consumed) ->
let input' = B32.slice input consumed (B32.len input) in
match parse32_fldata_strong s p32 (U32.v sz) sz input' with
| None -> None
| Some (x, consumed') ->
Some
((x <: parse_bounded_vldata_strong_t (U32.v min) (U32.v max) s),
consumed
`U32.add`
consumed'))
<:
(res: _{parser32_correct (parse_bounded_vlgen (U32.v min) (U32.v max) pk s) input res})) | false |
OPLSS.fst | OPLSS.bytes | val bytes : Type0 | let bytes = Seq.seq UInt8.t | {
"file_name": "examples/crypto/OPLSS.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 6,
"start_col": 0,
"start_line": 6
} | module OPLSS
module UInt8 = FStar.UInt8
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "OPLSS.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "UInt8"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"FStar.UInt8.t"
] | [] | false | false | false | true | true | let bytes =
| Seq.seq UInt8.t | false |
|
Steel.ST.HigherArray.fst | Steel.ST.HigherArray.memcpy0 | val memcpy0 (#t:_) (#p0:perm)
(a0 a1:array t)
(#s0 #s1:Ghost.erased (Seq.seq t))
(l:US.t { US.v l == length a0 /\ length a0 == length a1 } )
: STT unit
(pts_to a0 p0 s0 `star` pts_to a1 full_perm s1)
(fun _ -> pts_to a0 p0 s0 `star` pts_to a1 full_perm s0) | val memcpy0 (#t:_) (#p0:perm)
(a0 a1:array t)
(#s0 #s1:Ghost.erased (Seq.seq t))
(l:US.t { US.v l == length a0 /\ length a0 == length a1 } )
: STT unit
(pts_to a0 p0 s0 `star` pts_to a1 full_perm s1)
(fun _ -> pts_to a0 p0 s0 `star` pts_to a1 full_perm s0) | let memcpy0
#t #p0 a0 a1 #e0 #e1 i
=
pts_to_length a0 _;
pts_to_length a1 _;
let inv (j:Steel.ST.Loops.nat_at_most i)
: vprop
= pts_to a0 p0 e0 `star`
pts_to a1 full_perm (prefix_copied e0 e1 j)
in
assert (prefix_copied e0 e1 0 `Seq.equal` e1);
rewrite (pts_to a1 full_perm e1)
(pts_to a1 full_perm (prefix_copied e0 e1 0));
rewrite (pts_to a0 _ e0 `star` pts_to a1 full_perm (prefix_copied e0 e1 0))
(inv (US.v 0sz));
let body (j:Steel.ST.Loops.u32_between 0sz i)
: STT unit
(inv (US.v j))
(fun _ -> inv (US.v j + 1))
= rewrite
(inv (US.v j))
(pts_to a0 p0 e0 `star`
pts_to a1 full_perm (prefix_copied e0 e1 (US.v j)));
let z = index a0 j in
upd a1 j z;
assert (Seq.upd (prefix_copied e0 e1 (US.v j)) (US.v j) z `Seq.equal`
prefix_copied e0 e1 (US.v j + 1));
rewrite (pts_to a0 _ e0 `star` pts_to a1 _ _)
(inv (US.v j + 1));
return ()
in
Steel.ST.Loops.for_loop 0sz i inv body;
assert_ (inv (US.v i));
rewrite (inv (US.v i))
(pts_to a0 p0 e0 `star`
pts_to a1 full_perm (prefix_copied e0 e1 (US.v i)));
assert (prefix_copied e0 e1 (US.v i) `Seq.equal` e0);
rewrite (pts_to a1 _ (prefix_copied e0 e1 (US.v i)))
(pts_to a1 _ e0);
return () | {
"file_name": "lib/steel/Steel.ST.HigherArray.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 13,
"end_line": 646,
"start_col": 0,
"start_line": 607
} | (*
Copyright 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.HigherArray
module P = Steel.PCMFrac
module R = Steel.ST.PCMReference
module M = FStar.Map
module PM = Steel.PCMMap
[@@noextract_to "krml"]
let index_t (len: Ghost.erased nat) : Tot Type0 =
(i: nat { i < len })
[@@noextract_to "krml"]
let carrier (elt: Type u#a) (len: Ghost.erased nat) : Tot Type =
PM.map (index_t len) (P.fractional elt)
[@@noextract_to "krml"]
let pcm (elt: Type u#a) (len: Ghost.erased nat) : Tot (P.pcm (carrier elt len)) =
PM.pointwise (index_t len) (P.pcm_frac #elt)
[@@noextract_to "krml"]
let one (#elt: Type) (#len: Ghost.erased nat) = (pcm elt len).P.p.P.one
let composable (#elt: Type) (#len: Ghost.erased nat) = (pcm elt len).P.p.P.composable
[@@noextract_to "krml"]
let compose (#elt: Type) (#len: Ghost.erased nat) = (pcm elt len).P.p.P.op
[@@noextract_to "krml"]
let mk_carrier
(#elt: Type)
(len: nat)
(offset: nat)
(s: Seq.seq elt)
(p: P.perm)
: Tot (carrier elt len)
= let f (i: nat) : Tot (P.fractional elt) =
if offset + Seq.length s > len || i < offset || i >= offset + Seq.length s
then None
else Some (Seq.index s (i - offset), p)
in
M.map_literal f
let mk_carrier_inj
(#elt: Type)
(len: nat)
(offset: nat)
(s1 s2: Seq.seq elt)
(p1 p2: P.perm)
: Lemma
(requires (
mk_carrier len offset s1 p1 == mk_carrier len offset s2 p2 /\
offset + Seq.length s1 <= len /\
offset + Seq.length s2 <= len
))
(ensures (
s1 `Seq.equal` s2 /\
(Seq.length s1 > 0 ==> p1 == p2)
))
= assert (forall (i: nat) . i < Seq.length s1 ==>
(M.sel (mk_carrier len offset s1 p1) (offset + i) == Some (Seq.index s1 i, p1)));
assert (forall (i: nat) . i < Seq.length s2 ==>
M.sel (mk_carrier len offset s2 p2) (offset + i) == Some (Seq.index s2 i, p2))
[@@erasable]
let base_t (elt: Type u#a) : Tot Type0 = Ghost.erased (base_len: US.t & ref _ (pcm elt (US.v base_len)))
let base_len (#elt: Type) (b: base_t elt) : GTot nat = US.v (dfst b)
[@@noextract_to "krml"]
noeq
type ptr (elt: Type u#a) : Type0 = {
base_len: Ghost.erased US.t;
// U32.t to prove that A.read, A.write offset computation does not overflow. TODO: replace U32.t with size_t
base: (r: ref _ (pcm elt (US.v base_len)) { core_ref_is_null r ==> US.v base_len == 0 });
offset: (offset: nat { offset <= US.v base_len });
}
let null_ptr a = { base_len = 0sz; base = null #_ #(pcm a 0) ; offset = 0 }
let is_null_ptr p = is_null p.base
let base (#elt: Type) (p: ptr elt) : Tot (base_t elt) = (| Ghost.reveal p.base_len, p.base |)
let offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) = p.offset
let ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma
(requires (
base p1 == base p2 /\
offset p1 == offset p2
))
(ensures (
p1 == p2
))
= ()
let base_len_null_ptr _ = ()
let length_fits #elt a = ()
let valid_perm
(len: nat)
(offset: nat)
(slice_len: nat)
(p: P.perm) : Tot prop =
let open FStar.Real in
((offset + slice_len <= len /\ slice_len > 0) ==> (p.P.v <=. one))
[@__reduce__]
let pts_to0 (#elt: Type u#1) (a: array elt) (p: P.perm) (s: Seq.seq elt) : Tot vprop =
R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p) `star`
pure (
valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s) p /\
Seq.length s == length a
)
let pts_to (#elt: Type u#1) (a: array elt) ([@@@ smt_fallback ] p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop =
pts_to0 a p s
// this lemma is necessary because Steel.PCMReference is marked unfold
let change_r_pts_to
(#opened: _)
(#carrier: Type u#1)
(#pcm: P.pcm carrier)
(p: ref carrier pcm)
(v: carrier)
(#carrier': Type u#1)
(#pcm': P.pcm carrier')
(p': ref carrier' pcm')
(v': carrier')
: STGhost unit opened
(R.pts_to p v)
(fun _ -> R.pts_to p' v')
(// keep on distinct lines for error messages
carrier == carrier' /\
pcm == pcm' /\
p == p' /\
v == v')
(fun _ -> True)
= rewrite
(R.pts_to p v)
(R.pts_to p' v')
let intro_pts_to (#opened: _) (#elt: Type u#1) (a: array elt) (#v: _) (p: P.perm) (s: Seq.seq elt) : STGhost unit opened
(R.pts_to (ptr_of a).base v)
(fun _ -> pts_to a p s)
(
v == mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p /\
valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s) p /\
Seq.length s == length a
)
(fun _ -> True)
= change_r_pts_to (ptr_of a).base v (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p);
intro_pure _;
rewrite
(pts_to0 a p s)
(pts_to a p s)
let elim_pts_to (#opened: _) (#elt: Type u#1) (a: array elt) (p: P.perm) (s: Seq.seq elt) : STGhost unit opened
(pts_to a p s)
(fun _ -> R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p))
(True)
(fun _ ->
valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s) p /\
Seq.length s == length a
)
= rewrite
(pts_to a p s)
(pts_to0 a p s);
elim_pure _
let pts_to_length
a s
=
elim_pts_to a _ s;
intro_pts_to a _ s
let pts_to_not_null
a s
= elim_pts_to a _ s;
R.pts_to_not_null _ _;
intro_pts_to a _ s
let mk_carrier_joinable
(#elt: Type)
(len: nat)
(offset: nat)
(s1: Seq.seq elt)
(p1: P.perm)
(s2: Seq.seq elt)
(p2: P.perm)
: Lemma
(requires (
offset + Seq.length s1 <= len /\
Seq.length s1 == Seq.length s2 /\
P.joinable (pcm elt len) (mk_carrier len offset s1 p1) (mk_carrier len offset s2 p2)
))
(ensures (
s1 `Seq.equal` s2
))
=
let lem
(i: nat { 0 <= i /\ i < Seq.length s1 })
: Lemma
(Seq.index s1 i == Seq.index s2 i)
[SMTPat (Seq.index s1 i); SMTPat (Seq.index s2 i)]
= assert (
forall z . (
P.compatible (pcm elt len) (mk_carrier len offset s1 p1) z /\
P.compatible (pcm elt len) (mk_carrier len offset s2 p2) z
) ==>
begin match M.sel z (offset + i) with
| None -> False
| Some (v, _) -> v == Seq.index s1 i /\ v == Seq.index s2 i
end
)
in
()
let pure_star_interp' (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `Steel.Memory.star` Steel.Memory.pure q) m <==>
interp p m /\ q)
= pure_star_interp p q m;
emp_unit p
let pts_to_inj
a p1 s1 p2 s2 m
=
Classical.forall_intro reveal_pure;
pure_star_interp'
(hp_of (R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s1 p1)))
(
valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s1) p1 /\
Seq.length s1 == length a
)
m;
pure_star_interp'
(hp_of (R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s2 p2)))
(
valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s2) p2 /\
Seq.length s2 == length a
)
m;
pts_to_join
(ptr_of a).base
(mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s1 p1)
(mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s2 p2)
m;
mk_carrier_joinable (US.v (ptr_of a).base_len) (ptr_of a).offset s1 p1 s2 p2
[@@noextract_to "krml"]
let malloc0
(#elt: Type)
(x: elt)
(n: US.t)
: ST (array elt)
emp
(fun a -> pts_to a P.full_perm (Seq.create (US.v n) x))
(True)
(fun a ->
length a == US.v n /\
base_len (base (ptr_of a)) == US.v n
)
=
let c : carrier elt (US.v n) = mk_carrier (US.v n) 0 (Seq.create (US.v n) x) P.full_perm in
let base : ref (carrier elt (US.v n)) (pcm elt (US.v n)) = R.alloc c in
R.pts_to_not_null base _;
let p = {
base_len = n;
base = base;
offset = 0;
}
in
let a = (| p, Ghost.hide (US.v n) |) in
change_r_pts_to
base c
(ptr_of a).base c;
intro_pts_to a P.full_perm (Seq.create (US.v n) x);
return a
let malloc_ptr
x n
=
let a = malloc0 x n in
let (| p, _ |) = a in
rewrite
(pts_to _ _ _)
(pts_to (| p, Ghost.hide (US.v n) |) _ _);
return p
[@@noextract_to "krml"]
let free0
(#elt: Type)
(#s: Ghost.erased (Seq.seq elt))
(a: array elt)
: ST unit
(pts_to a P.full_perm s)
(fun _ -> emp)
(
length a == base_len (base (ptr_of a))
)
(fun _ -> True)
= drop (pts_to a _ _)
let free_ptr a =
free0 _
let valid_sum_perm
(len: nat)
(offset: nat)
(slice_len: nat)
(p1 p2: P.perm)
: Tot prop
= let open FStar.Real in
valid_perm len offset slice_len (P.sum_perm p1 p2)
let mk_carrier_share
(#elt: Type)
(len: nat)
(offset: nat)
(s: Seq.seq elt)
(p1 p2: P.perm)
: Lemma
(requires (valid_sum_perm len offset (Seq.length s) p1 p2))
(ensures (
let c1 = mk_carrier len offset s p1 in
let c2 = mk_carrier len offset s p2 in
composable c1 c2 /\
mk_carrier len offset s (p1 `P.sum_perm` p2) `M.equal` (c1 `compose` c2)
))
= ()
let share
#_ #_ #x a p p1 p2
= elim_pts_to a p x;
mk_carrier_share (US.v (ptr_of a).base_len) (ptr_of a).offset x p1 p2;
R.split (ptr_of a).base _
(mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset x p1)
(mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset x p2);
intro_pts_to a p1 x;
intro_pts_to a p2 x
let mk_carrier_gather
(#elt: Type)
(len: nat)
(offset: nat)
(s1 s2: Seq.seq elt)
(p1 p2: P.perm)
: Lemma
(requires (
let c1 = mk_carrier len offset s1 p1 in
let c2 = mk_carrier len offset s2 p2 in
composable c1 c2 /\
Seq.length s1 == Seq.length s2 /\
offset + Seq.length s1 <= len
))
(ensures (
let c1 = mk_carrier len offset s1 p1 in
let c2 = mk_carrier len offset s2 p2 in
composable c1 c2 /\
mk_carrier len offset s1 (p1 `P.sum_perm` p2) == (c1 `compose` c2) /\
mk_carrier len offset s2 (p1 `P.sum_perm` p2) == (c1 `compose` c2) /\
s1 == s2
))
=
let c1 = mk_carrier len offset s1 p1 in
let c2 = mk_carrier len offset s2 p2 in
assert (composable c1 c2);
assert (mk_carrier len offset s1 (p1 `P.sum_perm` p2) `M.equal` (c1 `compose` c2));
assert (mk_carrier len offset s2 (p1 `P.sum_perm` p2) `M.equal` (c1 `compose` c2));
mk_carrier_inj len offset s1 s2 (p1 `P.sum_perm` p2) (p1 `P.sum_perm` p2)
let mk_carrier_valid_sum_perm
(#elt: Type)
(len: nat)
(offset: nat)
(s: Seq.seq elt)
(p1 p2: P.perm)
: Lemma
(let c1 = mk_carrier len offset s p1 in
let c2 = mk_carrier len offset s p2 in
composable c1 c2 <==> valid_sum_perm len offset (Seq.length s) p1 p2)
= let c1 = mk_carrier len offset s p1 in
let c2 = mk_carrier len offset s p2 in
if Seq.length s > 0 && offset + Seq.length s <= len
then
let open FStar.Real in
assert (P.composable (M.sel c1 offset) (M.sel c2 offset) <==> valid_perm len offset (Seq.length s) (P.sum_perm p1 p2))
else ()
let gather
a #x1 p1 #x2 p2
= elim_pts_to a p1 x1;
elim_pts_to a p2 x2;
let _ = R.gather (ptr_of a).base
(mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset) x1 p1)
(mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset) x2 p2)
in
mk_carrier_gather (US.v (ptr_of a).base_len) ((ptr_of a).offset) x1 x2 p1 p2;
mk_carrier_valid_sum_perm (US.v (ptr_of a).base_len) ((ptr_of a).offset) x1 p1 p2;
intro_pts_to a (p1 `P.sum_perm` p2) x1
#push-options "--z3rlimit 16"
[@@noextract_to "krml"]
let index0
(#t: Type) (#p: P.perm)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t)
: ST t
(pts_to a p s)
(fun _ -> pts_to a p s)
(US.v i < length a \/ US.v i < Seq.length s)
(fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i))
= elim_pts_to a p s;
let s' = R.read (ptr_of a).base _ in
let res = fst (Some?.v (M.sel s' ((ptr_of a).offset + US.v i))) in
intro_pts_to a p s;
return res
#pop-options
let index_ptr a i =
index0 _ i
let mk_carrier_upd
(#elt: Type)
(len: nat)
(offset: nat)
(s: Seq.seq elt)
(i: nat)
(v: elt)
(_: squash (
offset + Seq.length s <= len /\
i < Seq.length s
))
: Lemma
(ensures (
let o = mk_carrier len offset s P.full_perm in
let o' = mk_carrier len offset (Seq.upd s i v) P.full_perm in
o' `Map.equal` Map.upd o (offset + i) (Some (v, P.full_perm))
))
= ()
#push-options "--z3rlimit 20"
[@@noextract_to "krml"]
let upd0
(#t: Type)
(a: array t)
(#s: Ghost.erased (Seq.seq t))
(i: US.t { US.v i < Seq.length s })
(v: t)
: STT unit
(pts_to a P.full_perm s)
(fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v))
= elim_pts_to a _ _;
mk_carrier_upd (US.v (ptr_of a).base_len) ((ptr_of a).offset) s (US.v i) v ();
R.upd_gen
(ptr_of a).base
_ _
(PM.lift_frame_preserving_upd
_ _
(P.mk_frame_preserving_upd
(Seq.index s (US.v i))
v
)
_ ((ptr_of a).offset + US.v i)
);
intro_pts_to a _ _
#pop-options
let upd_ptr a i v =
upd0 _ i v;
rewrite
(pts_to _ _ _)
(pts_to _ _ _)
let mk_carrier_merge
(#elt: Type)
(len: nat)
(offset: nat)
(s1 s2: Seq.seq elt)
(p: P.perm)
: Lemma
(requires (
offset + Seq.length s1 + Seq.length s2 <= len
))
(ensures (
let c1 = mk_carrier len offset s1 p in
let c2 = mk_carrier len (offset + Seq.length s1) s2 p in
composable c1 c2 /\
mk_carrier len offset (s1 `Seq.append` s2) p `M.equal` (c1 `compose` c2)
))
= ()
let ghost_join
#_ #_ #x1 #x2 #p a1 a2 h
= elim_pts_to a1 p x1;
elim_pts_to a2 p x2;
mk_carrier_merge (US.v (ptr_of a1).base_len) ((ptr_of a1).offset) x1 x2 (p);
change_r_pts_to
(ptr_of a2).base _
(ptr_of a1).base (mk_carrier (US.v (ptr_of a1).base_len) ((ptr_of a1).offset + Seq.length x1) x2 p);
R.gather (ptr_of a1).base
(mk_carrier (US.v (ptr_of a1).base_len) ((ptr_of a1).offset) x1 (p))
(mk_carrier (US.v (ptr_of a1).base_len) ((ptr_of a1).offset + Seq.length x1) x2 (p));
change_r_pts_to
(ptr_of a1).base _
(ptr_of (merge a1 a2)).base (mk_carrier (US.v (ptr_of (merge a1 a2)).base_len) ((ptr_of (merge a1 a2)).offset) (x1 `Seq.append` x2) (p));
intro_pts_to (merge a1 a2) p (Seq.append x1 x2)
let mk_carrier_split
(#elt: Type)
(len: nat)
(offset: nat)
(s: Seq.seq elt)
(p: P.perm)
(i: nat)
: Lemma
(requires (
offset + Seq.length s <= len /\
i <= Seq.length s
))
(ensures (
let c1 = mk_carrier len offset (Seq.slice s 0 i) p in
let c2 = mk_carrier len (offset + i) (Seq.slice s i (Seq.length s)) p in
composable c1 c2 /\
mk_carrier len offset s p `M.equal` (c1 `compose` c2)
))
= ()
// TODO: replace with Ghost, introduce pointer shifting operations in SteelAtomicBase Unobservable
[@@noextract_to "krml"]
let ptr_shift
(#elt: Type)
(p: ptr elt)
(off: US.t)
: Pure (ptr elt)
(requires (offset p + US.v off <= base_len (base p)))
(ensures (fun p' ->
base p' == base p /\
offset p' == offset p + US.v off
))
= {
base_len = p.base_len;
base = p.base;
offset = p.offset + US.v off;
}
let ghost_split
#_ #_ #x #p a i
=
elim_pts_to a p x;
mk_carrier_split
(US.v (ptr_of a).base_len)
((ptr_of a).offset)
x
(p)
(US.v i);
Seq.lemma_split x (US.v i);
let xl = Seq.slice x 0 (US.v i) in
let xr = Seq.slice x (US.v i) (Seq.length x) in
let vl = mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset) xl (p) in
let vr = mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset + US.v i) xr (p) in
R.split (ptr_of a).base _ vl vr;
change_r_pts_to
(ptr_of a).base vl
(ptr_of (split_l a i)).base vl;
intro_pts_to (split_l a i) #vl p (Seq.slice x 0 (US.v i));
change_r_pts_to
(ptr_of a).base vr
(ptr_of (split_r a i)).base vr;
intro_pts_to (split_r a i) #vr p (Seq.slice x (US.v i) (Seq.length x))
////////////////////////////////////////////////////////////////////////////////
// memcpy
////////////////////////////////////////////////////////////////////////////////
let prefix_copied #t
(e0:Seq.seq t)
(e1:Seq.seq t)
(i:nat { i <= Seq.length e0 /\ Seq.length e0 == Seq.length e1})
: Seq.seq t
= (Seq.append (Seq.slice e0 0 i) (Seq.slice e1 i (Seq.length e1)))
#push-options "--z3rlimit 32"
val memcpy0 (#t:_) (#p0:perm)
(a0 a1:array t)
(#s0 #s1:Ghost.erased (Seq.seq t))
(l:US.t { US.v l == length a0 /\ length a0 == length a1 } )
: STT unit
(pts_to a0 p0 s0 `star` pts_to a1 full_perm s1)
(fun _ -> pts_to a0 p0 s0 `star` pts_to a1 full_perm s0) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.PCMReference.fsti.checked",
"Steel.ST.Loops.fsti.checked",
"Steel.PCMMap.fst.checked",
"Steel.PCMFrac.fst.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.HigherArray.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.PCMMap",
"short_module": "PM"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Steel.ST.PCMReference",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "Steel.PCMFrac",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.PtrdiffT",
"short_module": "UP"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": true,
"full_module": "Steel.FractionalPermission",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a0: Steel.ST.HigherArray.array t ->
a1: Steel.ST.HigherArray.array t ->
l:
FStar.SizeT.t
{ FStar.SizeT.v l == Steel.ST.HigherArray.length a0 /\
Steel.ST.HigherArray.length a0 == Steel.ST.HigherArray.length a1 }
-> Steel.ST.Effect.STT Prims.unit | Steel.ST.Effect.STT | [] | [] | [
"Steel.FractionalPermission.perm",
"Steel.ST.HigherArray.array",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"FStar.SizeT.t",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"FStar.SizeT.v",
"Steel.ST.HigherArray.length",
"Steel.ST.Util.return",
"Prims.unit",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Steel.Effect.Common.VStar",
"Steel.ST.HigherArray.pts_to",
"Steel.FractionalPermission.full_perm",
"FStar.Ghost.reveal",
"Steel.Effect.Common.vprop",
"Steel.ST.Util.rewrite",
"Steel.ST.HigherArray.prefix_copied",
"Prims._assert",
"FStar.Seq.Base.equal",
"Steel.Effect.Common.star",
"Steel.ST.Util.assert_",
"Steel.ST.Loops.for_loop",
"FStar.SizeT.__uint_to_t",
"Steel.ST.Loops.u32_between",
"FStar.SizeT.uint_to_t",
"Prims.op_Addition",
"FStar.Seq.Base.upd",
"Steel.ST.HigherArray.upd",
"Steel.ST.HigherArray.index",
"Steel.ST.Loops.nat_at_most",
"Steel.ST.HigherArray.pts_to_length"
] | [] | false | true | false | false | false | let memcpy0 #t #p0 a0 a1 #e0 #e1 i =
| pts_to_length a0 _;
pts_to_length a1 _;
let inv (j: Steel.ST.Loops.nat_at_most i) : vprop =
(pts_to a0 p0 e0) `star` (pts_to a1 full_perm (prefix_copied e0 e1 j))
in
assert ((prefix_copied e0 e1 0) `Seq.equal` e1);
rewrite (pts_to a1 full_perm e1) (pts_to a1 full_perm (prefix_copied e0 e1 0));
rewrite ((pts_to a0 _ e0) `star` (pts_to a1 full_perm (prefix_copied e0 e1 0))) (inv (US.v 0sz));
let body (j: Steel.ST.Loops.u32_between 0sz i) : STT unit (inv (US.v j)) (fun _ -> inv (US.v j + 1))
=
rewrite (inv (US.v j))
((pts_to a0 p0 e0) `star` (pts_to a1 full_perm (prefix_copied e0 e1 (US.v j))));
let z = index a0 j in
upd a1 j z;
assert ((Seq.upd (prefix_copied e0 e1 (US.v j)) (US.v j) z)
`Seq.equal`
(prefix_copied e0 e1 (US.v j + 1)));
rewrite ((pts_to a0 _ e0) `star` (pts_to a1 _ _)) (inv (US.v j + 1));
return ()
in
Steel.ST.Loops.for_loop 0sz i inv body;
assert_ (inv (US.v i));
rewrite (inv (US.v i))
((pts_to a0 p0 e0) `star` (pts_to a1 full_perm (prefix_copied e0 e1 (US.v i))));
assert ((prefix_copied e0 e1 (US.v i)) `Seq.equal` e0);
rewrite (pts_to a1 _ (prefix_copied e0 e1 (US.v i))) (pts_to a1 _ e0);
return () | false |
OPLSS.fst | OPLSS.lbytes | val lbytes : l: Prims.nat -> Type0 | let lbytes l = b:bytes{Seq.length b = l} | {
"file_name": "examples/crypto/OPLSS.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 7,
"start_col": 0,
"start_line": 7
} | module OPLSS
module UInt8 = FStar.UInt8
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "OPLSS.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "UInt8"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.nat -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"OPLSS.bytes",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"FStar.UInt8.t"
] | [] | false | false | false | true | true | let lbytes l =
| b: bytes{Seq.length b = l} | false |
|
OPLSS.fst | OPLSS.auto_lemma_mem_snoc | val auto_lemma_mem_snoc : #a:eqtype -> s:Seq.seq a -> x:a -> y:a ->
Lemma
(ensures (mem y (snoc s x) <==> mem y s \/ x=y))
[SMTPat (mem y (snoc s x))] | val auto_lemma_mem_snoc : #a:eqtype -> s:Seq.seq a -> x:a -> y:a ->
Lemma
(ensures (mem y (snoc s x) <==> mem y s \/ x=y))
[SMTPat (mem y (snoc s x))] | let auto_lemma_mem_snoc #a s x y = Seq.lemma_mem_snoc s x | {
"file_name": "examples/crypto/OPLSS.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 57,
"end_line": 24,
"start_col": 0,
"start_line": 24
} | module OPLSS
module UInt8 = FStar.UInt8
module HS = FStar.HyperStack
module ST = FStar.HyperStack.ST
module B = LowStar.Monotonic.Buffer
let bytes = Seq.seq UInt8.t
let lbytes l = b:bytes{Seq.length b = l}
assume //demo scaffolding
val random (l:nat) : EXT (lbytes l)
assume //demo scaffolding
val byte_of_int: n:nat{n < 256} -> Tot UInt8.t
assume //demo scaffolding
val xor: l:nat -> lbytes l -> lbytes l -> Tot (lbytes l)
open FStar.Seq
val auto_lemma_mem_snoc : #a:eqtype -> s:Seq.seq a -> x:a -> y:a ->
Lemma
(ensures (mem y (snoc s x) <==> mem y s \/ x=y)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "OPLSS.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "UInt8"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq a -> x: a -> y: a
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Properties.mem y (FStar.Seq.Properties.snoc s x) <==>
FStar.Seq.Properties.mem y s \/ x = y)
[SMTPat (FStar.Seq.Properties.mem y (FStar.Seq.Properties.snoc s x))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"FStar.Seq.Base.seq",
"FStar.Seq.Properties.lemma_mem_snoc",
"Prims.unit"
] | [] | true | false | true | false | false | let auto_lemma_mem_snoc #a s x y =
| Seq.lemma_mem_snoc s x | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.parse_bounded_integer | val parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) | val parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) | let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 82,
"end_line": 64,
"start_col": 0,
"start_line": 60
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Spec.Base.parser (LowParse.Spec.BoundedInt.parse_bounded_integer_kind i)
(LowParse.Spec.BoundedInt.bounded_integer i) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.Combinators.make_total_constant_size_parser",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.decode_bounded_integer",
"Prims.unit",
"LowParse.Spec.BoundedInt.decode_bounded_integer_injective",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind"
] | [] | false | false | false | false | false | let parse_bounded_integer (i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) =
| decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.parse_bounded_integer_le | val parse_bounded_integer_le
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) | val parse_bounded_integer_le
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) | let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 81,
"end_line": 143,
"start_col": 0,
"start_line": 140
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Spec.Base.parser (LowParse.Spec.BoundedInt.parse_bounded_integer_kind i)
(LowParse.Spec.BoundedInt.bounded_integer i) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.Combinators.make_total_constant_size_parser",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.bounded_integer_of_le",
"Prims.unit",
"LowParse.Spec.BoundedInt.bounded_integer_of_le_injective",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind"
] | [] | false | false | false | false | false | let parse_bounded_integer_le i =
| bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.synth_u16_le | val synth_u16_le (x: bounded_integer 2) : Tot U16.t | val synth_u16_le (x: bounded_integer 2) : Tot U16.t | let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 25,
"end_line": 149,
"start_col": 0,
"start_line": 146
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: LowParse.Spec.BoundedInt.bounded_integer 2 -> FStar.UInt16.t | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.Int.Cast.uint32_to_uint16",
"FStar.UInt16.t"
] | [] | false | false | false | false | false | let synth_u16_le (x: bounded_integer 2) : Tot U16.t =
| Cast.uint32_to_uint16 x | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.synth_u32_le | val synth_u32_le (x: bounded_integer 4) : Tot U32.t | val synth_u32_le (x: bounded_integer 4) : Tot U32.t | let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 159,
"start_col": 0,
"start_line": 156
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: LowParse.Spec.BoundedInt.bounded_integer 4 -> FStar.UInt32.t | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt32.t"
] | [] | false | false | false | false | false | let synth_u32_le (x: bounded_integer 4) : Tot U32.t =
| x | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_bounded_integer | val serialize_bounded_integer
(sz: integer_size)
: Tot (serializer (parse_bounded_integer sz)) | val serialize_bounded_integer
(sz: integer_size)
: Tot (serializer (parse_bounded_integer sz)) | let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 31,
"end_line": 104,
"start_col": 0,
"start_line": 100
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Spec.Base.serializer (LowParse.Spec.BoundedInt.parse_bounded_integer sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.BoundedInt.serialize_bounded_integer'",
"Prims.unit",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_correct",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer"
] | [] | false | false | false | false | false | let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) =
| serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.bounded_integer_prop_equiv | val bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) | val bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) | let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 37,
"end_line": 26,
"start_col": 0,
"start_line": 17
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: LowParse.Spec.BoundedInt.integer_size -> u17: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.BoundedInt.bounded_integer_prop i u17 <==>
FStar.UInt32.v u17 < Prims.pow2 (8 * i)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"FStar.UInt32.t",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Prims.pow2",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"LowParse.Spec.BoundedInt.bounded_integer_prop",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"FStar.Mul.op_Star",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let bounded_integer_prop_equiv (i: integer_size) (u: U32.t)
: Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) =
| assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.parse_u32_le | val parse_u32_le : parser parse_u32_kind U32.t | val parse_u32_le : parser parse_u32_kind U32.t | let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 72,
"end_line": 161,
"start_col": 0,
"start_line": 161
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.Spec.Base.parser LowParse.Spec.Int.parse_u32_kind FStar.UInt32.t | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Combinators.parse_synth",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u32_le"
] | [] | false | false | false | true | false | let parse_u32_le =
| (parse_bounded_integer_le 4) `parse_synth` synth_u32_le | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.decode_bounded_integer_injective | val decode_bounded_integer_injective (i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) | val decode_bounded_integer_injective (i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) | let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 64,
"end_line": 58,
"start_col": 0,
"start_line": 54
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: LowParse.Spec.BoundedInt.integer_size
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Combinators.make_total_constant_size_parser_precond i
(LowParse.Spec.BoundedInt.bounded_integer i)
(LowParse.Spec.BoundedInt.decode_bounded_integer i)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"FStar.Classical.forall_intro_2",
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.l_imp",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.decode_bounded_integer",
"FStar.Seq.Base.equal",
"LowParse.Spec.BoundedInt.decode_bounded_integer_injective'",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"LowParse.Spec.Combinators.make_total_constant_size_parser_precond",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let decode_bounded_integer_injective (i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) =
| Classical.forall_intro_2 (decode_bounded_integer_injective' i) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.bounded_integer_of_le_injective | val bounded_integer_of_le_injective (i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) | val bounded_integer_of_le_injective (i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) | let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 63,
"end_line": 138,
"start_col": 0,
"start_line": 134
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: LowParse.Spec.BoundedInt.integer_size
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Combinators.make_total_constant_size_parser_precond i
(LowParse.Spec.BoundedInt.bounded_integer i)
(LowParse.Spec.BoundedInt.bounded_integer_of_le i)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"FStar.Classical.forall_intro_2",
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.l_imp",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.bounded_integer_of_le",
"FStar.Seq.Base.equal",
"LowParse.Spec.BoundedInt.bounded_integer_of_le_injective'",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"LowParse.Spec.Combinators.make_total_constant_size_parser_precond",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let bounded_integer_of_le_injective (i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) =
| Classical.forall_intro_2 (bounded_integer_of_le_injective' i) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_u16_le | val serialize_u16_le : serializer parse_u16_le | val serialize_u16_le : serializer parse_u16_le | let serialize_u16_le : serializer parse_u16_le =
serialize_synth
_
synth_u16_le
(serialize_bounded_integer_le 2)
synth_u16_le_recip
() | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 209,
"start_col": 0,
"start_line": 203
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz
inline_for_extraction
let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x
let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.Spec.Base.serializer LowParse.Spec.BoundedInt.parse_u16_le | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Combinators.serialize_synth",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt16.t",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u16_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u16_le_recip",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.Int.parse_u16_kind",
"LowParse.Spec.BoundedInt.parse_u16_le"
] | [] | false | false | false | true | false | let serialize_u16_le:serializer parse_u16_le =
| serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip () | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.parse_u16_le | val parse_u16_le : parser parse_u16_kind U16.t | val parse_u16_le : parser parse_u16_kind U16.t | let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 72,
"end_line": 153,
"start_col": 0,
"start_line": 153
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.Spec.Base.parser LowParse.Spec.Int.parse_u16_kind FStar.UInt16.t | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Combinators.parse_synth",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt16.t",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u16_le"
] | [] | false | false | false | true | false | let parse_u16_le =
| (parse_bounded_integer_le 2) `parse_synth` synth_u16_le | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_bounded_integer_le | val serialize_bounded_integer_le
(sz: integer_size)
: Tot (serializer (parse_bounded_integer_le sz)) | val serialize_bounded_integer_le
(sz: integer_size)
: Tot (serializer (parse_bounded_integer_le sz)) | let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 34,
"end_line": 193,
"start_col": 0,
"start_line": 190
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Spec.Base.serializer (LowParse.Spec.BoundedInt.parse_bounded_integer_le sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le'",
"Prims.unit",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le_correct",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le"
] | [] | false | false | false | false | false | let serialize_bounded_integer_le sz =
| serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.parse_bounded_int32 | val parse_bounded_int32
(min: nat)
(max: nat { 0 < max /\ min <= max /\ max < 4294967296 })
: Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max)) | val parse_bounded_int32
(min: nat)
(max: nat { 0 < max /\ min <= max /\ max < 4294967296 })
: Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max)) | let parse_bounded_int32
min max
= let sz = log256' max in
(parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 115,
"end_line": 228,
"start_col": 0,
"start_line": 225
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz
inline_for_extraction
let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x
let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = ()
let serialize_u16_le : serializer parse_u16_le =
serialize_synth
_
synth_u16_le
(serialize_bounded_integer_le 2)
synth_u16_le_recip
()
inline_for_extraction
let synth_u32_le_recip
(x: U32.t)
: Tot (bounded_integer 4)
= x
let serialize_u32_le =
serialize_synth
_
synth_u32_le
(serialize_bounded_integer_le 4)
synth_u32_le_recip
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | min: Prims.nat -> max: Prims.nat{0 < max /\ min <= max /\ max < 4294967296}
-> LowParse.Spec.Base.parser (LowParse.Spec.BoundedInt.parse_bounded_int32_kind max)
(LowParse.Spec.BoundedInt.bounded_int32 min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Combinators.parse_synth",
"LowParse.Spec.Combinators.parse_filter_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.Combinators.parse_filter_refine",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.in_bounds",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind"
] | [] | false | false | false | false | false | let parse_bounded_int32 min max =
| let sz = log256' max in
((parse_bounded_integer sz) `parse_filter` (in_bounds min max))
`parse_synth`
(fun x -> (x <: bounded_int32 min max)) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.synth_u16_le_recip | val synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) | val synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) | let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 25,
"end_line": 199,
"start_col": 0,
"start_line": 196
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt16.t -> LowParse.Spec.BoundedInt.bounded_integer 2 | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt16.t",
"FStar.Int.Cast.uint16_to_uint32",
"LowParse.Spec.BoundedInt.bounded_integer"
] | [] | false | false | false | false | false | let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) =
| Cast.uint16_to_uint32 x | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.parse_bounded_int32_le | val parse_bounded_int32_le
(min: nat)
(max: nat { 0 < max /\ min <= max /\ max < 4294967296 })
: Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max)) | val parse_bounded_int32_le
(min: nat)
(max: nat { 0 < max /\ min <= max /\ max < 4294967296 })
: Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max)) | let parse_bounded_int32_le
min max
= let sz = log256' max in
(parse_bounded_integer_le sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 118,
"end_line": 243,
"start_col": 0,
"start_line": 240
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz
inline_for_extraction
let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x
let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = ()
let serialize_u16_le : serializer parse_u16_le =
serialize_synth
_
synth_u16_le
(serialize_bounded_integer_le 2)
synth_u16_le_recip
()
inline_for_extraction
let synth_u32_le_recip
(x: U32.t)
: Tot (bounded_integer 4)
= x
let serialize_u32_le =
serialize_synth
_
synth_u32_le
(serialize_bounded_integer_le 4)
synth_u32_le_recip
()
let parse_bounded_int32
min max
= let sz = log256' max in
(parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max))
let serialize_bounded_int32
min max
= let sz = log256' max in
serialize_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer sz) (in_bounds min max))
(fun x -> x)
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | min: Prims.nat -> max: Prims.nat{0 < max /\ min <= max /\ max < 4294967296}
-> LowParse.Spec.Base.parser (LowParse.Spec.BoundedInt.parse_bounded_int32_kind max)
(LowParse.Spec.BoundedInt.bounded_int32 min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Combinators.parse_synth",
"LowParse.Spec.Combinators.parse_filter_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.Combinators.parse_filter_refine",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.in_bounds",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind"
] | [] | false | false | false | false | false | let parse_bounded_int32_le min max =
| let sz = log256' max in
((parse_bounded_integer_le sz) `parse_filter` (in_bounds min max))
`parse_synth`
(fun x -> (x <: bounded_int32 min max)) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.parse_bounded_integer_spec | val parse_bounded_integer_spec
(i: integer_size)
(input: bytes)
: Lemma
(let res = parse (parse_bounded_integer i) input in
if Seq.length input < i
then res == None
else
match res with
| None -> False
| Some (y, consumed) ->
U32.v y == E.be_to_n (Seq.slice input 0 i) /\ consumed == i
) | val parse_bounded_integer_spec
(i: integer_size)
(input: bytes)
: Lemma
(let res = parse (parse_bounded_integer i) input in
if Seq.length input < i
then res == None
else
match res with
| None -> False
| Some (y, consumed) ->
U32.v y == E.be_to_n (Seq.slice input 0 i) /\ consumed == i
) | let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input' | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 62,
"end_line": 74,
"start_col": 0,
"start_line": 66
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: LowParse.Spec.BoundedInt.integer_size -> input: LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(ensures
(let res =
LowParse.Spec.Base.parse (LowParse.Spec.BoundedInt.parse_bounded_integer i) input
in
(match FStar.Seq.Base.length input < i with
| true -> res == FStar.Pervasives.Native.None
| _ ->
(match res with
| FStar.Pervasives.Native.None #_ -> Prims.l_False
| FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ y consumed) ->
FStar.UInt32.v y == FStar.Endianness.be_to_n (FStar.Seq.Base.slice input 0 i) /\
consumed == i)
<:
Type0)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.parse",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse_strong_prefix",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"Prims.unit",
"FStar.Endianness.lemma_be_to_n_is_bounded",
"FStar.Seq.Base.seq",
"LowParse.Bytes.byte",
"FStar.Seq.Base.slice",
"FStar.Math.Lemmas.pow2_le_compat",
"FStar.Mul.op_Star",
"LowParse.Spec.Base.parser_kind_prop_equiv"
] | [] | false | false | true | false | false | let parse_bounded_integer_spec i input =
| parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input' | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_u32_le | val serialize_u32_le : serializer parse_u32_le | val serialize_u32_le : serializer parse_u32_le | let serialize_u32_le =
serialize_synth
_
synth_u32_le
(serialize_bounded_integer_le 4)
synth_u32_le_recip
() | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 223,
"start_col": 0,
"start_line": 217
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz
inline_for_extraction
let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x
let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = ()
let serialize_u16_le : serializer parse_u16_le =
serialize_synth
_
synth_u16_le
(serialize_bounded_integer_le 2)
synth_u16_le_recip
()
inline_for_extraction
let synth_u32_le_recip
(x: U32.t)
: Tot (bounded_integer 4)
= x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.Spec.Base.serializer LowParse.Spec.BoundedInt.parse_u32_le | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Combinators.serialize_synth",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u32_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u32_le_recip"
] | [] | false | false | false | true | false | let serialize_u32_le =
| serialize_synth _ synth_u32_le (serialize_bounded_integer_le 4) synth_u32_le_recip () | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_bounded_int32 | val serialize_bounded_int32
(min: nat)
(max: nat { 0 < max /\ min <= max /\ max < 4294967296 })
: Tot (serializer (parse_bounded_int32 min max)) | val serialize_bounded_int32
(min: nat)
(max: nat { 0 < max /\ min <= max /\ max < 4294967296 })
: Tot (serializer (parse_bounded_int32 min max)) | let serialize_bounded_int32
min max
= let sz = log256' max in
serialize_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer sz) (in_bounds min max))
(fun x -> x)
() | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 238,
"start_col": 0,
"start_line": 230
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz
inline_for_extraction
let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x
let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = ()
let serialize_u16_le : serializer parse_u16_le =
serialize_synth
_
synth_u16_le
(serialize_bounded_integer_le 2)
synth_u16_le_recip
()
inline_for_extraction
let synth_u32_le_recip
(x: U32.t)
: Tot (bounded_integer 4)
= x
let serialize_u32_le =
serialize_synth
_
synth_u32_le
(serialize_bounded_integer_le 4)
synth_u32_le_recip
()
let parse_bounded_int32
min max
= let sz = log256' max in
(parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | min: Prims.nat -> max: Prims.nat{0 < max /\ min <= max /\ max < 4294967296}
-> LowParse.Spec.Base.serializer (LowParse.Spec.BoundedInt.parse_bounded_int32 min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Combinators.serialize_synth",
"LowParse.Spec.Combinators.parse_filter_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.Combinators.parse_filter_refine",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.in_bounds",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.Combinators.serialize_filter",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.parse_bounded_int32"
] | [] | false | false | false | false | false | let serialize_bounded_int32 min max =
| let sz = log256' max in
serialize_synth ((parse_bounded_integer sz) `parse_filter` (in_bounds min max))
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer sz) (in_bounds min max))
(fun x -> x)
() | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_bounded_int32_le_fixed_size | val serialize_bounded_int32_le_fixed_size
(min: nat)
(max: nat { min <= max })
: Tot (serializer (parse_bounded_int32_le_fixed_size min max)) | val serialize_bounded_int32_le_fixed_size
(min: nat)
(max: nat { min <= max })
: Tot (serializer (parse_bounded_int32_le_fixed_size min max)) | let serialize_bounded_int32_le_fixed_size
min max
= serialize_filter serialize_u32_le (in_bounds min max) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 55,
"end_line": 261,
"start_col": 0,
"start_line": 259
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz
inline_for_extraction
let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x
let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = ()
let serialize_u16_le : serializer parse_u16_le =
serialize_synth
_
synth_u16_le
(serialize_bounded_integer_le 2)
synth_u16_le_recip
()
inline_for_extraction
let synth_u32_le_recip
(x: U32.t)
: Tot (bounded_integer 4)
= x
let serialize_u32_le =
serialize_synth
_
synth_u32_le
(serialize_bounded_integer_le 4)
synth_u32_le_recip
()
let parse_bounded_int32
min max
= let sz = log256' max in
(parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max))
let serialize_bounded_int32
min max
= let sz = log256' max in
serialize_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer sz) (in_bounds min max))
(fun x -> x)
()
let parse_bounded_int32_le
min max
= let sz = log256' max in
(parse_bounded_integer_le sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max))
let serialize_bounded_int32_le
min max
= let sz = log256' max in
serialize_synth
(parse_bounded_integer_le sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer_le sz) (in_bounds min max))
(fun x -> x)
()
let parse_bounded_int32_le_fixed_size
min max
= parse_filter parse_u32_le (in_bounds min max) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | min: Prims.nat -> max: Prims.nat{min <= max}
-> LowParse.Spec.Base.serializer (LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size min
max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Combinators.serialize_filter",
"LowParse.Spec.Int.parse_u32_kind",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.parse_u32_le",
"LowParse.Spec.BoundedInt.serialize_u32_le",
"LowParse.Spec.BoundedInt.in_bounds",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size"
] | [] | false | false | false | false | false | let serialize_bounded_int32_le_fixed_size min max =
| serialize_filter serialize_u32_le (in_bounds min max) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size | val parse_bounded_int32_le_fixed_size
(min: nat)
(max: nat { min <= max })
: Tot (parser parse_bounded_int32_fixed_size_kind (bounded_int32 min max)) | val parse_bounded_int32_le_fixed_size
(min: nat)
(max: nat { min <= max })
: Tot (parser parse_bounded_int32_fixed_size_kind (bounded_int32 min max)) | let parse_bounded_int32_le_fixed_size
min max
= parse_filter parse_u32_le (in_bounds min max) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 47,
"end_line": 257,
"start_col": 0,
"start_line": 255
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz
inline_for_extraction
let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x
let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = ()
let serialize_u16_le : serializer parse_u16_le =
serialize_synth
_
synth_u16_le
(serialize_bounded_integer_le 2)
synth_u16_le_recip
()
inline_for_extraction
let synth_u32_le_recip
(x: U32.t)
: Tot (bounded_integer 4)
= x
let serialize_u32_le =
serialize_synth
_
synth_u32_le
(serialize_bounded_integer_le 4)
synth_u32_le_recip
()
let parse_bounded_int32
min max
= let sz = log256' max in
(parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max))
let serialize_bounded_int32
min max
= let sz = log256' max in
serialize_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer sz) (in_bounds min max))
(fun x -> x)
()
let parse_bounded_int32_le
min max
= let sz = log256' max in
(parse_bounded_integer_le sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max))
let serialize_bounded_int32_le
min max
= let sz = log256' max in
serialize_synth
(parse_bounded_integer_le sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer_le sz) (in_bounds min max))
(fun x -> x)
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | min: Prims.nat -> max: Prims.nat{min <= max}
-> LowParse.Spec.Base.parser LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind
(LowParse.Spec.BoundedInt.bounded_int32 min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.Int.parse_u32_kind",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.parse_u32_le",
"LowParse.Spec.BoundedInt.in_bounds",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind",
"LowParse.Spec.BoundedInt.bounded_int32"
] | [] | false | false | false | false | false | let parse_bounded_int32_le_fixed_size min max =
| parse_filter parse_u32_le (in_bounds min max) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_bounded_int32_le | val serialize_bounded_int32_le
(min: nat)
(max: nat { 0 < max /\ min <= max /\ max < 4294967296 })
: Tot (serializer (parse_bounded_int32_le min max)) | val serialize_bounded_int32_le
(min: nat)
(max: nat { 0 < max /\ min <= max /\ max < 4294967296 })
: Tot (serializer (parse_bounded_int32_le min max)) | let serialize_bounded_int32_le
min max
= let sz = log256' max in
serialize_synth
(parse_bounded_integer_le sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer_le sz) (in_bounds min max))
(fun x -> x)
() | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 253,
"start_col": 0,
"start_line": 245
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz
inline_for_extraction
let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x
let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = ()
let serialize_u16_le : serializer parse_u16_le =
serialize_synth
_
synth_u16_le
(serialize_bounded_integer_le 2)
synth_u16_le_recip
()
inline_for_extraction
let synth_u32_le_recip
(x: U32.t)
: Tot (bounded_integer 4)
= x
let serialize_u32_le =
serialize_synth
_
synth_u32_le
(serialize_bounded_integer_le 4)
synth_u32_le_recip
()
let parse_bounded_int32
min max
= let sz = log256' max in
(parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max))
let serialize_bounded_int32
min max
= let sz = log256' max in
serialize_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer sz) (in_bounds min max))
(fun x -> x)
()
let parse_bounded_int32_le
min max
= let sz = log256' max in
(parse_bounded_integer_le sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | min: Prims.nat -> max: Prims.nat{0 < max /\ min <= max /\ max < 4294967296}
-> LowParse.Spec.Base.serializer (LowParse.Spec.BoundedInt.parse_bounded_int32_le min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Combinators.serialize_synth",
"LowParse.Spec.Combinators.parse_filter_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.Combinators.parse_filter_refine",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.in_bounds",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.Combinators.serialize_filter",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le",
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.Spec.Base.serializer",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le"
] | [] | false | false | false | false | false | let serialize_bounded_int32_le min max =
| let sz = log256' max in
serialize_synth ((parse_bounded_integer_le sz) `parse_filter` (in_bounds min max))
(fun x -> (x <: bounded_int32 min max))
(serialize_filter (serialize_bounded_integer_le sz) (in_bounds min max))
(fun x -> x)
() | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.synth_u32_le_recip | val synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) | val synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) | let synth_u32_le_recip
(x: U32.t)
: Tot (bounded_integer 4)
= x | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 215,
"start_col": 0,
"start_line": 212
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16"
let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
#pop-options
let serialize_bounded_integer_le
sz
= serialize_bounded_integer_le_correct sz;
serialize_bounded_integer_le' sz
inline_for_extraction
let synth_u16_le_recip
(x: U16.t)
: Tot (bounded_integer 2)
= Cast.uint16_to_uint32 x
let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = ()
let serialize_u16_le : serializer parse_u16_le =
serialize_synth
_
synth_u16_le
(serialize_bounded_integer_le 2)
synth_u16_le_recip
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt32.t -> LowParse.Spec.BoundedInt.bounded_integer 4 | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.bounded_integer"
] | [] | false | false | false | false | false | let synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) =
| x | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.decode_bounded_integer_injective' | val decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes{Seq.length b1 == i})
(b2: bytes{Seq.length b2 == i})
: Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) | val decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes{Seq.length b1 == i})
(b2: bytes{Seq.length b2 == i})
: Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) | let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else () | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 52,
"start_col": 0,
"start_line": 38
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
i: LowParse.Spec.BoundedInt.integer_size ->
b1: LowParse.Bytes.bytes{FStar.Seq.Base.length b1 == i} ->
b2: LowParse.Bytes.bytes{FStar.Seq.Base.length b2 == i}
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.BoundedInt.decode_bounded_integer i b1 ==
LowParse.Spec.BoundedInt.decode_bounded_integer i b2 ==>
FStar.Seq.Base.equal b1 b2) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.op_Equality",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.decode_bounded_integer",
"FStar.Endianness.be_to_n_inj",
"Prims.unit",
"Prims._assert",
"FStar.Endianness.be_to_n",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"FStar.Endianness.lemma_be_to_n_is_bounded",
"Prims.bool",
"Prims.l_True",
"Prims.squash",
"Prims.l_imp",
"FStar.Seq.Base.equal",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes{Seq.length b1 == i})
(b2: bytes{Seq.length b2 == i})
: Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) =
| if decode_bounded_integer i b1 = decode_bounded_integer i b2
then
(E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.decode_bounded_integer | val decode_bounded_integer (i: integer_size) (b: bytes{Seq.length b == i})
: GTot (bounded_integer i) | val decode_bounded_integer (i: integer_size) (b: bytes{Seq.length b == i})
: GTot (bounded_integer i) | let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 29,
"end_line": 36,
"start_col": 0,
"start_line": 30
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: LowParse.Spec.BoundedInt.integer_size -> b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == i}
-> Prims.GTot (LowParse.Spec.BoundedInt.bounded_integer i) | Prims.GTot | [
"sometrivial"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"FStar.UInt32.uint_to_t",
"FStar.Endianness.be_to_n",
"Prims.unit",
"FStar.Math.Lemmas.pow2_le_compat",
"FStar.Mul.op_Star",
"FStar.Endianness.lemma_be_to_n_is_bounded",
"LowParse.Spec.BoundedInt.bounded_integer"
] | [] | false | false | false | false | false | let decode_bounded_integer (i: integer_size) (b: bytes{Seq.length b == i})
: GTot (bounded_integer i) =
| E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_bounded_integer' | val serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) | val serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) | let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 82,
"start_col": 0,
"start_line": 76
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Spec.Base.bare_serializer (LowParse.Spec.BoundedInt.bounded_integer sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.Endianness.bytes",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"FStar.UInt8.t",
"FStar.UInt32.v",
"FStar.Endianness.be_to_n",
"FStar.Endianness.n_to_be",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.bare_serializer"
] | [] | false | false | false | false | false | let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) =
| (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.bounded_integer_of_le | val bounded_integer_of_le (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i) | val bounded_integer_of_le (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i) | let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 29,
"end_line": 114,
"start_col": 0,
"start_line": 108
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: LowParse.Spec.BoundedInt.integer_size -> b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == i}
-> Prims.GTot (LowParse.Spec.BoundedInt.bounded_integer i) | Prims.GTot | [
"sometrivial"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"FStar.UInt32.uint_to_t",
"FStar.Endianness.le_to_n",
"Prims.unit",
"FStar.Math.Lemmas.pow2_le_compat",
"FStar.Mul.op_Star",
"FStar.Endianness.lemma_le_to_n_is_bounded",
"LowParse.Spec.BoundedInt.bounded_integer"
] | [] | false | false | false | false | false | let bounded_integer_of_le (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i) =
| E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_bounded_integer_le' | val serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) | val serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) | let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
) | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 3,
"end_line": 168,
"start_col": 0,
"start_line": 163
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Spec.Base.bare_serializer (LowParse.Spec.BoundedInt.bounded_integer sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.Endianness.n_to_le",
"FStar.UInt32.v",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.bare_serializer"
] | [] | false | false | false | false | false | let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) =
| (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x)) | false |
Steel.ST.C.Types.Array.Base.fst | Steel.ST.C.Types.Array.Base.array_domain | val array_domain (n: Ghost.erased SZ.t) : Tot eqtype | val array_domain (n: Ghost.erased SZ.t) : Tot eqtype | let array_domain
(n: Ghost.erased SZ.t)
: Tot eqtype
= (i: SZ.t { SZ.v i < SZ.v n }) | {
"file_name": "lib/steel/c/Steel.ST.C.Types.Array.Base.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 31,
"end_line": 8,
"start_col": 0,
"start_line": 5
} | module Steel.ST.C.Types.Array.Base
module SZ = FStar.SizeT | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.C.Types.Array.Base.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "SZ"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Array",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Array",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: FStar.Ghost.erased FStar.SizeT.t -> Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.Ghost.erased",
"FStar.SizeT.t",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.SizeT.v",
"FStar.Ghost.reveal",
"Prims.eqtype"
] | [] | false | false | false | true | false | let array_domain (n: Ghost.erased SZ.t) : Tot eqtype =
| (i: SZ.t{SZ.v i < SZ.v n}) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.bounded_integer_of_le_injective' | val bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes{Seq.length b1 == i})
(b2: bytes{Seq.length b2 == i})
: Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) | val bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes{Seq.length b1 == i})
(b2: bytes{Seq.length b2 == i})
: Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) | let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else () | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 130,
"start_col": 0,
"start_line": 116
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
i: LowParse.Spec.BoundedInt.integer_size ->
b1: LowParse.Bytes.bytes{FStar.Seq.Base.length b1 == i} ->
b2: LowParse.Bytes.bytes{FStar.Seq.Base.length b2 == i}
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.BoundedInt.bounded_integer_of_le i b1 ==
LowParse.Spec.BoundedInt.bounded_integer_of_le i b2 ==>
FStar.Seq.Base.equal b1 b2) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Bytes.bytes",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.op_Equality",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.bounded_integer_of_le",
"FStar.Endianness.le_to_n_inj",
"Prims.unit",
"Prims._assert",
"FStar.Endianness.le_to_n",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"FStar.Endianness.lemma_le_to_n_is_bounded",
"Prims.bool",
"Prims.l_True",
"Prims.squash",
"Prims.l_imp",
"FStar.Seq.Base.equal",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes{Seq.length b1 == i})
(b2: bytes{Seq.length b2 == i})
: Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) =
| if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then
(E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2) | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.params_nbar | val params_nbar : FStar.UInt32.t | let params_nbar = 8ul | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 48,
"start_col": 0,
"start_line": 48
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.UInt32.t | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | false | let params_nbar =
| 8ul | false |
|
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.bytes_seed_a | val bytes_seed_a : FStar.UInt32.t | let bytes_seed_a = 16ul | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 51,
"start_col": 0,
"start_line": 51
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.UInt32.t | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | false | let bytes_seed_a =
| 16ul | false |
|
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.bytes_pkhash | val bytes_pkhash : a: Spec.Frodo.Params.frodo_alg
-> x:
Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{Lib.IntTypes.v x == Spec.Frodo.Params.crypto_bytes a} | let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 55,
"start_col": 0,
"start_line": 54
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg
-> x:
Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{Lib.IntTypes.v x == Spec.Frodo.Params.crypto_bytes a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Lib.IntTypes.v",
"Spec.Frodo.Params.crypto_bytes"
] | [] | false | false | false | false | false | let bytes_pkhash (a: S.frodo_alg) =
| crypto_bytes a | false |
|
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_bounded_integer_correct | val serialize_bounded_integer_correct (sz: integer_size)
: Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) | val serialize_bounded_integer_correct (sz: integer_size)
: Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) | let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 28,
"end_line": 98,
"start_col": 0,
"start_line": 84
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.serializer_correct (LowParse.Spec.BoundedInt.parse_bounded_integer sz)
(LowParse.Spec.BoundedInt.serialize_bounded_integer' sz)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"FStar.Classical.forall_intro",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.BoundedInt.serialize_bounded_integer'",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.serializer_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind"
] | [] | false | false | true | false | false | let serialize_bounded_integer_correct (sz: integer_size)
: Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) =
| let prf (x: bounded_integer sz)
: Lemma
(let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
) =
()
in
Classical.forall_intro prf | false |
Pulse.Checker.Prover.fst | Pulse.Checker.Prover.coerce_eq | val coerce_eq: #a: Type -> #b: Type -> x: a -> squash (a == b) -> y: b{y == x} | val coerce_eq: #a: Type -> #b: Type -> x: a -> squash (a == b) -> y: b{y == x} | let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 70,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module RU = Pulse.RuntimeUtils
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Pprint = FStar.Stubs.Pprint
module Metatheory = Pulse.Typing.Metatheory
module PS = Pulse.Checker.Prover.Substs
module ElimExists = Pulse.Checker.Prover.ElimExists
module ElimPure = Pulse.Checker.Prover.ElimPure
module Match = Pulse.Checker.Prover.Match
module IntroExists = Pulse.Checker.Prover.IntroExists
module IntroPure = Pulse.Checker.Prover.IntroPure | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Readback.fsti.checked",
"Pulse.PP.fst.checked",
"Pulse.Config.fsti.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Prover.Match.fsti.checked",
"Pulse.Checker.Prover.IntroPure.fsti.checked",
"Pulse.Checker.Prover.IntroExists.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Stubs.Pprint.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroPure",
"short_module": "IntroPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroExists",
"short_module": "IntroExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "FStar.Stubs.Pprint",
"short_module": "Pprint"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"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.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> _: Prims.squash (a == b) -> y: b{y == x} | Prims.Tot | [
"total"
] | [] | [
"Prims.squash",
"Prims.eq2"
] | [] | false | false | false | false | false | let coerce_eq (#a: Type) (#b: Type) (x: a) (_: squash (a == b)) : y: b{y == x} =
| x | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.publicmatrixbytes_len | val publicmatrixbytes_len : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul) | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 63,
"start_col": 0,
"start_line": 62
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Frodo.Params.params_logq",
"Lib.IntTypes.op_Slash_Dot",
"Hacl.Impl.Frodo.Params.params_n",
"Hacl.Impl.Frodo.Params.params_nbar",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t"
] | [] | false | false | false | true | false | let publicmatrixbytes_len (a: S.frodo_alg) =
| params_logq a *! (params_n a *! params_nbar /. 8ul) | false |
|
Pulse.Checker.Prover.fst | Pulse.Checker.Prover.collect_pures | val collect_pures (g: env) (l: list vprop)
: pures: list vprop &
rest: list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (rest @ pures)) | val collect_pures (g: env) (l: list vprop)
: pures: list vprop &
rest: list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (rest @ pures)) | let rec collect_pures (g:env) (l:list vprop)
: pures:list vprop &
rest:list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (rest @ pures)) =
match l with
| [] -> (| [], [], VE_Refl _ _ |)
| hd::tl ->
let (| pures, rest, _ |) = collect_pures g tl in
match hd.t with
| Tm_Pure _ -> (| hd::pures, rest, RU.magic #(vprop_equiv _ _ _) () |)
| _ -> (| pures, hd::rest, RU.magic #(vprop_equiv _ _ _) () |) | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 66,
"end_line": 83,
"start_col": 0,
"start_line": 72
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module RU = Pulse.RuntimeUtils
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Pprint = FStar.Stubs.Pprint
module Metatheory = Pulse.Typing.Metatheory
module PS = Pulse.Checker.Prover.Substs
module ElimExists = Pulse.Checker.Prover.ElimExists
module ElimPure = Pulse.Checker.Prover.ElimPure
module Match = Pulse.Checker.Prover.Match
module IntroExists = Pulse.Checker.Prover.IntroExists
module IntroPure = Pulse.Checker.Prover.IntroPure
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x
let elim_exists_and_pure (#g:env) (#ctxt:vprop)
(ctxt_typing:tot_typing g ctxt tm_vprop)
: T.Tac (g':env { env_extends g' g } &
ctxt':term &
tot_typing g' ctxt' tm_vprop &
continuation_elaborator g ctxt g' ctxt') =
let (| g1, ctxt1, d1, k1 |) = ElimExists.elim_exists ctxt_typing in
let (| g2, ctxt2, d2, k2 |) = ElimPure.elim_pure d1 in
(| g2, ctxt2, d2, k_elab_trans k1 k2 |)
let unsolved_equiv_pst (#preamble:_) (pst:prover_state preamble) (unsolved':list vprop)
(d:vprop_equiv (push_env pst.pg pst.uvs) (list_as_vprop pst.unsolved) (list_as_vprop unsolved'))
: prover_state preamble =
{ pst with unsolved = unsolved'; goals_inv = RU.magic () }
let rec collect_exists (g:env) (l:list vprop)
: exs:list vprop &
rest:list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) =
match l with
| [] -> (| [], [], VE_Refl _ _ |)
| hd::tl ->
let (| exs, rest, _ |) = collect_exists g tl in
match hd.t with
| Tm_ExistsSL _ _ _ ->
(| hd::exs, rest, RU.magic #(vprop_equiv _ _ _) () |)
| _ -> (| exs, hd::rest, RU.magic #(vprop_equiv _ _ _) () |) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Readback.fsti.checked",
"Pulse.PP.fst.checked",
"Pulse.Config.fsti.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Prover.Match.fsti.checked",
"Pulse.Checker.Prover.IntroPure.fsti.checked",
"Pulse.Checker.Prover.IntroExists.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Stubs.Pprint.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroPure",
"short_module": "IntroPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroExists",
"short_module": "IntroExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "FStar.Stubs.Pprint",
"short_module": "Pprint"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"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.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | g: Pulse.Typing.Env.env -> l: Prims.list Pulse.Syntax.Base.vprop
-> FStar.Pervasives.dtuple3 (Prims.list Pulse.Syntax.Base.vprop)
(fun _ -> Prims.list Pulse.Syntax.Base.vprop)
(fun pures rest ->
Pulse.Typing.vprop_equiv g
(Pulse.Typing.Combinators.list_as_vprop l)
(Pulse.Typing.Combinators.list_as_vprop (rest @ pures))) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Typing.Env.env",
"Prims.list",
"Pulse.Syntax.Base.vprop",
"FStar.Pervasives.Mkdtuple3",
"Pulse.Typing.vprop_equiv",
"Pulse.Typing.Combinators.list_as_vprop",
"FStar.List.Tot.Base.op_At",
"Prims.Nil",
"Pulse.Typing.VE_Refl",
"Pulse.Syntax.Base.__proj__Mkterm__item__t",
"Pulse.Syntax.Base.term",
"Prims.Cons",
"Pulse.RuntimeUtils.magic",
"Pulse.Syntax.Base.term'",
"FStar.Pervasives.dtuple3",
"Pulse.Checker.Prover.collect_pures"
] | [
"recursion"
] | false | false | false | false | false | let rec collect_pures (g: env) (l: list vprop)
: pures: list vprop &
rest: list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (rest @ pures)) =
| match l with
| [] -> (| [], [], VE_Refl _ _ |)
| hd :: tl ->
let (| pures , rest , _ |) = collect_pures g tl in
match hd.t with
| Tm_Pure _ -> (| hd :: pures, rest, RU.magic #(vprop_equiv _ _ _) () |)
| _ -> (| pures, hd :: rest, RU.magic #(vprop_equiv _ _ _) () |) | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.is_supported | val is_supported : a: Spec.Frodo.Params.frodo_gen_a -> Prims.bool | let is_supported (a:S.frodo_gen_a) =
match a with
| S.SHAKE128 -> true
| S.AES128 -> false | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 114,
"start_col": 0,
"start_line": 111
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul)
inline_for_extraction noextract
let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a
inline_for_extraction noextract
let crypto_secretkeybytes (a:S.frodo_alg) =
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a
inline_for_extraction noextract
let crypto_ciphertextbytes (a:S.frodo_alg) =
ct1bytes_len a +! ct2bytes_len a
inline_for_extraction noextract
let frodo_shake_st (a:S.frodo_alg) =
inputByteLen:size_t
-> input:lbuffer uint8 inputByteLen
-> outputByteLen:size_t
-> output:lbuffer uint8 outputByteLen
-> Stack unit
(requires fun h ->
live h input /\ live h output /\ disjoint input output)
(ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\
as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen))
inline_for_extraction noextract
let frodo_shake (a:S.frodo_alg) : frodo_shake_st a =
match a with
| S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl
| S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_gen_a -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_gen_a",
"Prims.bool"
] | [] | false | false | false | true | false | let is_supported (a: S.frodo_gen_a) =
| match a with
| S.SHAKE128 -> true
| S.AES128 -> false | false |
|
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.frodo_shake_st | val frodo_shake_st : a: Spec.Frodo.Params.frodo_alg -> Type0 | let frodo_shake_st (a:S.frodo_alg) =
inputByteLen:size_t
-> input:lbuffer uint8 inputByteLen
-> outputByteLen:size_t
-> output:lbuffer uint8 outputByteLen
-> Stack unit
(requires fun h ->
live h input /\ live h output /\ disjoint input output)
(ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\
as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 95,
"end_line": 100,
"start_col": 0,
"start_line": 91
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul)
inline_for_extraction noextract
let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a
inline_for_extraction noextract
let crypto_secretkeybytes (a:S.frodo_alg) =
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a
inline_for_extraction noextract
let crypto_ciphertextbytes (a:S.frodo_alg) =
ct1bytes_len a +! ct2bytes_len a | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Spec.Frodo.Params.frodo_shake"
] | [] | false | false | false | true | true | let frodo_shake_st (a: S.frodo_alg) =
|
inputByteLen: size_t ->
input: lbuffer uint8 inputByteLen ->
outputByteLen: size_t ->
output: lbuffer uint8 outputByteLen
-> Stack unit
(requires fun h -> live h input /\ live h output /\ disjoint input output)
(ensures
fun h0 _ h1 ->
modifies (loc output) h0 h1 /\
as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) | false |
|
Pulse.Checker.Prover.fst | Pulse.Checker.Prover.collect_exists | val collect_exists (g: env) (l: list vprop)
: exs: list vprop &
rest: list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) | val collect_exists (g: env) (l: list vprop)
: exs: list vprop &
rest: list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) | let rec collect_exists (g:env) (l:list vprop)
: exs:list vprop &
rest:list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) =
match l with
| [] -> (| [], [], VE_Refl _ _ |)
| hd::tl ->
let (| exs, rest, _ |) = collect_exists g tl in
match hd.t with
| Tm_ExistsSL _ _ _ ->
(| hd::exs, rest, RU.magic #(vprop_equiv _ _ _) () |)
| _ -> (| exs, hd::rest, RU.magic #(vprop_equiv _ _ _) () |) | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 64,
"end_line": 70,
"start_col": 0,
"start_line": 58
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module RU = Pulse.RuntimeUtils
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Pprint = FStar.Stubs.Pprint
module Metatheory = Pulse.Typing.Metatheory
module PS = Pulse.Checker.Prover.Substs
module ElimExists = Pulse.Checker.Prover.ElimExists
module ElimPure = Pulse.Checker.Prover.ElimPure
module Match = Pulse.Checker.Prover.Match
module IntroExists = Pulse.Checker.Prover.IntroExists
module IntroPure = Pulse.Checker.Prover.IntroPure
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x
let elim_exists_and_pure (#g:env) (#ctxt:vprop)
(ctxt_typing:tot_typing g ctxt tm_vprop)
: T.Tac (g':env { env_extends g' g } &
ctxt':term &
tot_typing g' ctxt' tm_vprop &
continuation_elaborator g ctxt g' ctxt') =
let (| g1, ctxt1, d1, k1 |) = ElimExists.elim_exists ctxt_typing in
let (| g2, ctxt2, d2, k2 |) = ElimPure.elim_pure d1 in
(| g2, ctxt2, d2, k_elab_trans k1 k2 |)
let unsolved_equiv_pst (#preamble:_) (pst:prover_state preamble) (unsolved':list vprop)
(d:vprop_equiv (push_env pst.pg pst.uvs) (list_as_vprop pst.unsolved) (list_as_vprop unsolved'))
: prover_state preamble =
{ pst with unsolved = unsolved'; goals_inv = RU.magic () } | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Readback.fsti.checked",
"Pulse.PP.fst.checked",
"Pulse.Config.fsti.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Prover.Match.fsti.checked",
"Pulse.Checker.Prover.IntroPure.fsti.checked",
"Pulse.Checker.Prover.IntroExists.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Stubs.Pprint.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroPure",
"short_module": "IntroPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroExists",
"short_module": "IntroExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "FStar.Stubs.Pprint",
"short_module": "Pprint"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"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.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | g: Pulse.Typing.Env.env -> l: Prims.list Pulse.Syntax.Base.vprop
-> FStar.Pervasives.dtuple3 (Prims.list Pulse.Syntax.Base.vprop)
(fun _ -> Prims.list Pulse.Syntax.Base.vprop)
(fun exs rest ->
Pulse.Typing.vprop_equiv g
(Pulse.Typing.Combinators.list_as_vprop l)
(Pulse.Typing.Combinators.list_as_vprop (exs @ rest))) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Typing.Env.env",
"Prims.list",
"Pulse.Syntax.Base.vprop",
"FStar.Pervasives.Mkdtuple3",
"Pulse.Typing.vprop_equiv",
"Pulse.Typing.Combinators.list_as_vprop",
"FStar.List.Tot.Base.op_At",
"Prims.Nil",
"Pulse.Typing.VE_Refl",
"Pulse.Syntax.Base.__proj__Mkterm__item__t",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.binder",
"Pulse.Syntax.Base.term",
"Prims.Cons",
"Pulse.RuntimeUtils.magic",
"Pulse.Syntax.Base.term'",
"FStar.Pervasives.dtuple3",
"Pulse.Checker.Prover.collect_exists"
] | [
"recursion"
] | false | false | false | false | false | let rec collect_exists (g: env) (l: list vprop)
: exs: list vprop &
rest: list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) =
| match l with
| [] -> (| [], [], VE_Refl _ _ |)
| hd :: tl ->
let (| exs , rest , _ |) = collect_exists g tl in
match hd.t with
| Tm_ExistsSL _ _ _ -> (| hd :: exs, rest, RU.magic #(vprop_equiv _ _ _) () |)
| _ -> (| exs, hd :: rest, RU.magic #(vprop_equiv _ _ _) () |) | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.params_logq | val params_logq (a: S.frodo_alg) : x: size_t{v x == S.params_logq a} | val params_logq (a: S.frodo_alg) : x: size_t{v x == S.params_logq a} | let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 28,
"start_col": 0,
"start_line": 25
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg
-> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.params_logq a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Frodo.Params.params_logq"
] | [] | false | false | false | false | false | let params_logq (a: S.frodo_alg) : x: size_t{v x == S.params_logq a} =
| match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.secretmatrixbytes_len | val secretmatrixbytes_len : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 67,
"start_col": 0,
"start_line": 66
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Frodo.Params.params_n",
"Hacl.Impl.Frodo.Params.params_nbar",
"Lib.IntTypes.int_t"
] | [] | false | false | false | true | false | let secretmatrixbytes_len (a: S.frodo_alg) =
| 2ul *! params_n a *! params_nbar | false |
|
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.crypto_publickeybytes | val crypto_publickeybytes : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 79,
"start_col": 0,
"start_line": 78
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Frodo.Params.bytes_seed_a",
"Hacl.Impl.Frodo.Params.publicmatrixbytes_len",
"Lib.IntTypes.int_t"
] | [] | false | false | false | true | false | let crypto_publickeybytes (a: S.frodo_alg) =
| bytes_seed_a +! publicmatrixbytes_len a | false |
|
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.crypto_ciphertextbytes | val crypto_ciphertextbytes : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | let crypto_ciphertextbytes (a:S.frodo_alg) =
ct1bytes_len a +! ct2bytes_len a | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 87,
"start_col": 0,
"start_line": 86
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul)
inline_for_extraction noextract
let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a
inline_for_extraction noextract
let crypto_secretkeybytes (a:S.frodo_alg) =
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Frodo.Params.ct1bytes_len",
"Hacl.Impl.Frodo.Params.ct2bytes_len",
"Lib.IntTypes.int_t"
] | [] | false | false | false | true | false | let crypto_ciphertextbytes (a: S.frodo_alg) =
| ct1bytes_len a +! ct2bytes_len a | false |
|
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.ct1bytes_len | val ct1bytes_len : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul) | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 71,
"start_col": 0,
"start_line": 70
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Frodo.Params.params_logq",
"Lib.IntTypes.op_Slash_Dot",
"Hacl.Impl.Frodo.Params.params_nbar",
"Hacl.Impl.Frodo.Params.params_n",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t"
] | [] | false | false | false | true | false | let ct1bytes_len (a: S.frodo_alg) =
| params_logq a *! (params_nbar *! params_n a /. 8ul) | false |
|
Pulse.Checker.Prover.fst | Pulse.Checker.Prover.elim_exists_and_pure | val elim_exists_and_pure (#g:env) (#ctxt:vprop)
(ctxt_typing:tot_typing g ctxt tm_vprop)
: T.Tac (g':env { env_extends g' g } &
ctxt':term &
tot_typing g' ctxt' tm_vprop &
continuation_elaborator g ctxt g' ctxt') | val elim_exists_and_pure (#g:env) (#ctxt:vprop)
(ctxt_typing:tot_typing g ctxt tm_vprop)
: T.Tac (g':env { env_extends g' g } &
ctxt':term &
tot_typing g' ctxt' tm_vprop &
continuation_elaborator g ctxt g' ctxt') | let elim_exists_and_pure (#g:env) (#ctxt:vprop)
(ctxt_typing:tot_typing g ctxt tm_vprop)
: T.Tac (g':env { env_extends g' g } &
ctxt':term &
tot_typing g' ctxt' tm_vprop &
continuation_elaborator g ctxt g' ctxt') =
let (| g1, ctxt1, d1, k1 |) = ElimExists.elim_exists ctxt_typing in
let (| g2, ctxt2, d2, k2 |) = ElimPure.elim_pure d1 in
(| g2, ctxt2, d2, k_elab_trans k1 k2 |) | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 41,
"end_line": 51,
"start_col": 0,
"start_line": 42
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module RU = Pulse.RuntimeUtils
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Pprint = FStar.Stubs.Pprint
module Metatheory = Pulse.Typing.Metatheory
module PS = Pulse.Checker.Prover.Substs
module ElimExists = Pulse.Checker.Prover.ElimExists
module ElimPure = Pulse.Checker.Prover.ElimPure
module Match = Pulse.Checker.Prover.Match
module IntroExists = Pulse.Checker.Prover.IntroExists
module IntroPure = Pulse.Checker.Prover.IntroPure
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Readback.fsti.checked",
"Pulse.PP.fst.checked",
"Pulse.Config.fsti.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Prover.Match.fsti.checked",
"Pulse.Checker.Prover.IntroPure.fsti.checked",
"Pulse.Checker.Prover.IntroExists.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Stubs.Pprint.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroPure",
"short_module": "IntroPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroExists",
"short_module": "IntroExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "FStar.Stubs.Pprint",
"short_module": "Pprint"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ctxt_typing: Pulse.Typing.tot_typing g ctxt Pulse.Syntax.Base.tm_vprop
-> FStar.Tactics.Effect.Tac
(FStar.Pervasives.dtuple4 (g': Pulse.Typing.Env.env{Pulse.Typing.Env.env_extends g' g})
(fun _ -> Pulse.Syntax.Base.term)
(fun g' ctxt' -> Pulse.Typing.tot_typing g' ctxt' Pulse.Syntax.Base.tm_vprop)
(fun g' ctxt' _ -> Pulse.Checker.Base.continuation_elaborator g ctxt g' ctxt')) | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.vprop",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.Env.env_extends",
"Pulse.Syntax.Base.term",
"Pulse.Checker.Base.continuation_elaborator",
"FStar.Pervasives.Mkdtuple4",
"Pulse.Checker.Base.k_elab_trans",
"FStar.Pervasives.dtuple4",
"Pulse.Checker.Prover.ElimPure.elim_pure",
"Pulse.Checker.Prover.ElimExists.elim_exists"
] | [] | false | true | false | false | false | let elim_exists_and_pure (#g: env) (#ctxt: vprop) (ctxt_typing: tot_typing g ctxt tm_vprop)
: T.Tac
(g': env{env_extends g' g} &
ctxt': term &
tot_typing g' ctxt' tm_vprop &
continuation_elaborator g ctxt g' ctxt') =
| let (| g1 , ctxt1 , d1 , k1 |) = ElimExists.elim_exists ctxt_typing in
let (| g2 , ctxt2 , d2 , k2 |) = ElimPure.elim_pure d1 in
(| g2, ctxt2, d2, k_elab_trans k1 k2 |) | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.crypto_bytes | val crypto_bytes (a: S.frodo_alg) : x: size_t{v x == S.crypto_bytes a} | val crypto_bytes (a: S.frodo_alg) : x: size_t{v x == S.crypto_bytes a} | let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 44,
"start_col": 0,
"start_line": 40
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg
-> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.crypto_bytes a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Frodo.Params.crypto_bytes"
] | [] | false | false | false | false | false | let crypto_bytes (a: S.frodo_alg) : x: size_t{v x == S.crypto_bytes a} =
| match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.ct2bytes_len | val ct2bytes_len : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul) | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 75,
"start_col": 0,
"start_line": 74
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Frodo.Params.params_logq",
"Lib.IntTypes.op_Slash_Dot",
"Hacl.Impl.Frodo.Params.params_nbar",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t"
] | [] | false | false | false | true | false | let ct2bytes_len (a: S.frodo_alg) =
| params_logq a *! (params_nbar *! params_nbar /. 8ul) | false |
|
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.bytes_mu | val bytes_mu (a: S.frodo_alg) : x: size_t{v x == S.bytes_mu a} | val bytes_mu (a: S.frodo_alg) : x: size_t{v x == S.bytes_mu a} | let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 59,
"start_col": 0,
"start_line": 58
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg
-> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.bytes_mu a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.op_Slash_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.PUB",
"Hacl.Impl.Frodo.Params.params_extracted_bits",
"Hacl.Impl.Frodo.Params.params_nbar",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.v",
"Spec.Frodo.Params.bytes_mu"
] | [] | false | false | false | false | false | let bytes_mu (a: S.frodo_alg) : x: size_t{v x == S.bytes_mu a} =
| params_extracted_bits a *! params_nbar *! params_nbar /. 8ul | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.params_extracted_bits | val params_extracted_bits (a: S.frodo_alg) : x: size_t{v x == S.params_extracted_bits a} | val params_extracted_bits (a: S.frodo_alg) : x: size_t{v x == S.params_extracted_bits a} | let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 36,
"start_col": 0,
"start_line": 32
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg
-> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.params_extracted_bits a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.op_LessThan",
"Spec.Frodo.Params.params_logq",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Frodo.Params.params_extracted_bits"
] | [] | false | false | false | false | false | let params_extracted_bits (a: S.frodo_alg) : x: size_t{v x == S.params_extracted_bits a} =
| match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.crypto_secretkeybytes | val crypto_secretkeybytes : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | let crypto_secretkeybytes (a:S.frodo_alg) =
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 88,
"end_line": 83,
"start_col": 0,
"start_line": 82
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul)
inline_for_extraction noextract
let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"Hacl.Impl.Frodo.Params.secretmatrixbytes_len",
"Hacl.Impl.Frodo.Params.bytes_pkhash",
"Lib.IntTypes.int_t"
] | [] | false | false | false | true | false | let crypto_secretkeybytes (a: S.frodo_alg) =
| crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a | false |
|
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.frodo_shake | val frodo_shake (a: S.frodo_alg) : frodo_shake_st a | val frodo_shake (a: S.frodo_alg) : frodo_shake_st a | let frodo_shake (a:S.frodo_alg) : frodo_shake_st a =
match a with
| S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl
| S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 107,
"start_col": 0,
"start_line": 104
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul)
inline_for_extraction noextract
let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a
inline_for_extraction noextract
let crypto_secretkeybytes (a:S.frodo_alg) =
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a
inline_for_extraction noextract
let crypto_ciphertextbytes (a:S.frodo_alg) =
ct1bytes_len a +! ct2bytes_len a
inline_for_extraction noextract
let frodo_shake_st (a:S.frodo_alg) =
inputByteLen:size_t
-> input:lbuffer uint8 inputByteLen
-> outputByteLen:size_t
-> output:lbuffer uint8 outputByteLen
-> Stack unit
(requires fun h ->
live h input /\ live h output /\ disjoint input output)
(ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\
as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg -> Hacl.Impl.Frodo.Params.frodo_shake_st a | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"Hacl.SHA3.shake128_hacl",
"Hacl.SHA3.shake256_hacl",
"Hacl.Impl.Frodo.Params.frodo_shake_st"
] | [] | false | false | false | false | false | let frodo_shake (a: S.frodo_alg) : frodo_shake_st a =
| match a with
| S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl
| S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl | false |
Pulse.Checker.Prover.fst | Pulse.Checker.Prover.get_q_at_hd | val get_q_at_hd (g: env) (l: list vprop) (q: vprop{L.existsb (fun v -> eq_tm v q) l})
: l': list vprop & vprop_equiv g (list_as_vprop l) (q * list_as_vprop l') | val get_q_at_hd (g: env) (l: list vprop) (q: vprop{L.existsb (fun v -> eq_tm v q) l})
: l': list vprop & vprop_equiv g (list_as_vprop l) (q * list_as_vprop l') | let rec get_q_at_hd (g:env) (l:list vprop) (q:vprop { L.existsb (fun v -> eq_tm v q) l })
: l':list vprop &
vprop_equiv g (list_as_vprop l) (q * list_as_vprop l') =
match l with
| hd::tl ->
if eq_tm hd q then (| tl, RU.magic #(vprop_equiv _ _ _) () |)
else let (| tl', _ |) = get_q_at_hd g tl q in
(| hd::tl', RU.magic #(vprop_equiv _ _ _) () |) | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 56,
"end_line": 190,
"start_col": 0,
"start_line": 182
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module RU = Pulse.RuntimeUtils
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Pprint = FStar.Stubs.Pprint
module Metatheory = Pulse.Typing.Metatheory
module PS = Pulse.Checker.Prover.Substs
module ElimExists = Pulse.Checker.Prover.ElimExists
module ElimPure = Pulse.Checker.Prover.ElimPure
module Match = Pulse.Checker.Prover.Match
module IntroExists = Pulse.Checker.Prover.IntroExists
module IntroPure = Pulse.Checker.Prover.IntroPure
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x
let elim_exists_and_pure (#g:env) (#ctxt:vprop)
(ctxt_typing:tot_typing g ctxt tm_vprop)
: T.Tac (g':env { env_extends g' g } &
ctxt':term &
tot_typing g' ctxt' tm_vprop &
continuation_elaborator g ctxt g' ctxt') =
let (| g1, ctxt1, d1, k1 |) = ElimExists.elim_exists ctxt_typing in
let (| g2, ctxt2, d2, k2 |) = ElimPure.elim_pure d1 in
(| g2, ctxt2, d2, k_elab_trans k1 k2 |)
let unsolved_equiv_pst (#preamble:_) (pst:prover_state preamble) (unsolved':list vprop)
(d:vprop_equiv (push_env pst.pg pst.uvs) (list_as_vprop pst.unsolved) (list_as_vprop unsolved'))
: prover_state preamble =
{ pst with unsolved = unsolved'; goals_inv = RU.magic () }
let rec collect_exists (g:env) (l:list vprop)
: exs:list vprop &
rest:list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) =
match l with
| [] -> (| [], [], VE_Refl _ _ |)
| hd::tl ->
let (| exs, rest, _ |) = collect_exists g tl in
match hd.t with
| Tm_ExistsSL _ _ _ ->
(| hd::exs, rest, RU.magic #(vprop_equiv _ _ _) () |)
| _ -> (| exs, hd::rest, RU.magic #(vprop_equiv _ _ _) () |)
let rec collect_pures (g:env) (l:list vprop)
: pures:list vprop &
rest:list vprop &
vprop_equiv g (list_as_vprop l) (list_as_vprop (rest @ pures)) =
match l with
| [] -> (| [], [], VE_Refl _ _ |)
| hd::tl ->
let (| pures, rest, _ |) = collect_pures g tl in
match hd.t with
| Tm_Pure _ -> (| hd::pures, rest, RU.magic #(vprop_equiv _ _ _) () |)
| _ -> (| pures, hd::rest, RU.magic #(vprop_equiv _ _ _) () |)
let rec prove_pures #preamble (pst:prover_state preamble)
: T.Tac (pst':prover_state preamble { pst' `pst_extends` pst /\
is_terminal pst' }) =
match pst.unsolved with
| [] -> pst
| {t=Tm_Pure p}::unsolved' ->
let pst_opt = IntroPure.intro_pure pst p unsolved' () in
(match pst_opt with
| None ->
let open Pulse.PP in
fail_doc pst.pg None [
text "Cannot prove pure proposition" ^/^
pp p
]
| Some pst1 ->
let pst2 = prove_pures pst1 in
assert (pst1 `pst_extends` pst);
assert (pst2 `pst_extends` pst1);
assert (pst2 `pst_extends` pst);
pst2)
| _ ->
fail pst.pg None
(Printf.sprintf "Impossible! prover.prove_pures: %s is not a pure, please file a bug-report"
(P.term_to_string (L.hd pst.unsolved)))
#push-options "--z3rlimit_factor 4"
let rec prover
(#preamble:_)
(pst0:prover_state preamble)
: T.Tac (pst':prover_state preamble { pst' `pst_extends` pst0 /\
is_terminal pst' }) =
debug_prover pst0.pg (fun _ ->
Printf.sprintf "At the prover top-level with remaining_ctxt: %s\nunsolved: %s"
(P.term_to_string (list_as_vprop pst0.remaining_ctxt))
(P.term_to_string (list_as_vprop pst0.unsolved)));
match pst0.unsolved with
| [] -> pst0
| _ ->
let pst = ElimExists.elim_exists_pst pst0 in
debug_prover pst.pg (fun _ ->
Printf.sprintf "prover: remaining_ctxt after elim exists: %s\n"
(P.term_to_string (list_as_vprop pst.remaining_ctxt)));
let pst = ElimPure.elim_pure_pst pst in
debug_prover pst.pg (fun _ ->
Printf.sprintf "prover: remaining_ctxt after elim pure: %s\n"
(P.term_to_string (list_as_vprop pst.remaining_ctxt)));
let (| exs, rest, d |) = collect_exists (push_env pst.pg pst.uvs) pst.unsolved in
debug_prover pst.pg (fun _ ->
Printf.sprintf "prover: tried to pull exists: exs: %s and rest: %s\n"
(P.term_to_string (list_as_vprop exs)) (P.term_to_string (list_as_vprop rest)));
let pst = unsolved_equiv_pst pst (exs@rest) d in
debug_prover pst.pg (fun _ ->
Printf.sprintf "prover: unsolved after pulling exists at the top: %s\n"
(P.term_to_string (list_as_vprop pst.unsolved)));
match pst.unsolved with
| {t=Tm_ExistsSL u b body}::unsolved' ->
IntroExists.intro_exists pst u b body unsolved' () prover
| _ ->
let (| pures, rest, d |) = collect_pures (push_env pst.pg pst.uvs) pst.unsolved in
let pst = unsolved_equiv_pst pst (rest@pures) d in
match pst.unsolved with
| {t=Tm_Pure _}::tl -> prove_pures pst
| q::tl ->
let pst_opt = Match.match_q pst q tl () prover in
match pst_opt with
| None ->
let open Pprint in
let open Pulse.PP in
let msg = [
text "Cannot prove:" ^^
indent (pp q);
text "In the context:" ^^
indent (pp (list_as_vprop pst.remaining_ctxt))
] @ (if Pulse.Config.debug_flag "initial_solver_state" then [
text "The prover was started with goal:" ^^
indent (pp preamble.goals);
text "and initial context:" ^^
indent (pp preamble.ctxt);
] else [])
in
// GM: I feel I should use (Some q.range) instead of None, but that makes
// several error locations worse.
fail_doc pst.pg None msg
| Some pst -> prover pst // a little wasteful?
#pop-options | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Readback.fsti.checked",
"Pulse.PP.fst.checked",
"Pulse.Config.fsti.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Prover.Match.fsti.checked",
"Pulse.Checker.Prover.IntroPure.fsti.checked",
"Pulse.Checker.Prover.IntroExists.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Stubs.Pprint.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroPure",
"short_module": "IntroPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroExists",
"short_module": "IntroExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "FStar.Stubs.Pprint",
"short_module": "Pprint"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"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.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
g: Pulse.Typing.Env.env ->
l: Prims.list Pulse.Syntax.Base.vprop ->
q: Pulse.Syntax.Base.vprop{FStar.List.Tot.Base.existsb (fun v -> Pulse.Syntax.Base.eq_tm v q) l}
-> Prims.dtuple2 (Prims.list Pulse.Syntax.Base.vprop)
(fun l' ->
Pulse.Typing.vprop_equiv g
(Pulse.Typing.Combinators.list_as_vprop l)
(q * Pulse.Typing.Combinators.list_as_vprop l')) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Typing.Env.env",
"Prims.list",
"Pulse.Syntax.Base.vprop",
"Prims.b2t",
"FStar.List.Tot.Base.existsb",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.eq_tm",
"Prims.bool",
"Prims.Mkdtuple2",
"Pulse.Typing.vprop_equiv",
"Pulse.Typing.Combinators.list_as_vprop",
"Pulse.Checker.Prover.Base.op_Star",
"Pulse.RuntimeUtils.magic",
"Prims.Cons",
"Prims.dtuple2",
"Pulse.Checker.Prover.get_q_at_hd"
] | [
"recursion"
] | false | false | false | false | false | let rec get_q_at_hd (g: env) (l: list vprop) (q: vprop{L.existsb (fun v -> eq_tm v q) l})
: l': list vprop & vprop_equiv g (list_as_vprop l) (q * list_as_vprop l') =
| match l with
| hd :: tl ->
if eq_tm hd q
then (| tl, RU.magic #(vprop_equiv _ _ _) () |)
else
let (| tl' , _ |) = get_q_at_hd g tl q in
(| hd :: tl', RU.magic #(vprop_equiv _ _ _) () |) | false |
LowParse.Spec.BoundedInt.fst | LowParse.Spec.BoundedInt.serialize_bounded_integer_le_correct | val serialize_bounded_integer_le_correct (sz: integer_size)
: Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) | val serialize_bounded_integer_le_correct (sz: integer_size)
: Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) | let serialize_bounded_integer_le_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf | {
"file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 28,
"end_line": 186,
"start_col": 0,
"start_line": 172
} | module LowParse.Spec.BoundedInt
open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond
module Seq = FStar.Seq
module E = FStar.Endianness
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module M = LowParse.Math
module Cast = FStar.Int.Cast
(* bounded integers *)
let integer_size_values i = ()
let bounded_integer_prop_equiv
(i: integer_size)
(u: U32.t)
: Lemma
(bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
=
assert_norm (pow2 8 == 256);
assert_norm (pow2 16 == 65536);
assert_norm (pow2 24 == 16777216);
assert_norm (pow2 32 == 4294967296)
#push-options "--z3rlimit 16"
let decode_bounded_integer
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_be_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.be_to_n b)
let decode_bounded_integer_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
= if decode_bounded_integer i b1 = decode_bounded_integer i b2
then begin
E.lemma_be_to_n_is_bounded b1;
E.lemma_be_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1);
assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2);
assert (E.be_to_n b1 == E.be_to_n b2);
E.be_to_n_inj b1 b2
end else ()
let decode_bounded_integer_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
= Classical.forall_intro_2 (decode_bounded_integer_injective' i)
let parse_bounded_integer
(i: integer_size)
: Tot (parser (parse_bounded_integer_kind i) (bounded_integer i))
= decode_bounded_integer_injective i;
make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
let parse_bounded_integer_spec i input =
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i);
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
match parse (parse_bounded_integer i) input with
| None -> ()
| Some (y, consumed) ->
let input' = Seq.slice input 0 i in
E.lemma_be_to_n_is_bounded input';
parse_strong_prefix (parse_bounded_integer i) input input'
let serialize_bounded_integer'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
let res = E.n_to_be sz (U32.v x) in
res
)
let serialize_bounded_integer_correct
(sz: integer_size)
: Lemma
(serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
= let prf
(x: bounded_integer sz)
: Lemma
(
let res = serialize_bounded_integer' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer sz) res == Some (x, (sz <: nat))
)
= ()
in
Classical.forall_intro prf
let serialize_bounded_integer
sz
: Tot (serializer (parse_bounded_integer sz))
= serialize_bounded_integer_correct sz;
serialize_bounded_integer' sz
let serialize_bounded_integer_spec sz x = ()
let bounded_integer_of_le
(i: integer_size)
(b: bytes { Seq.length b == i } )
: GTot (bounded_integer i)
= E.lemma_le_to_n_is_bounded b;
M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i);
U32.uint_to_t (E.le_to_n b)
let bounded_integer_of_le_injective'
(i: integer_size)
(b1: bytes { Seq.length b1 == i } )
(b2: bytes { Seq.length b2 == i } )
: Lemma
(bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
= if bounded_integer_of_le i b1 = bounded_integer_of_le i b2
then begin
E.lemma_le_to_n_is_bounded b1;
E.lemma_le_to_n_is_bounded b2;
assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1);
assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2);
assert (E.le_to_n b1 == E.le_to_n b2);
E.le_to_n_inj b1 b2
end else ()
#pop-options
let bounded_integer_of_le_injective
(i: integer_size)
: Lemma
(make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
= Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
let parse_bounded_integer_le
i
= bounded_integer_of_le_injective i;
make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i)
inline_for_extraction
let synth_u16_le
(x: bounded_integer 2)
: Tot U16.t
= Cast.uint32_to_uint16 x
let synth_u16_le_injective : squash (synth_injective synth_u16_le) = ()
let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le
inline_for_extraction
let synth_u32_le
(x: bounded_integer 4)
: Tot U32.t
= x
let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le
let serialize_bounded_integer_le'
(sz: integer_size)
: Tot (bare_serializer (bounded_integer sz))
= (fun (x: bounded_integer sz) ->
E.n_to_le sz (U32.v x)
)
#push-options "--z3rlimit 16" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.BoundedInt.fst"
} | [
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.serializer_correct (LowParse.Spec.BoundedInt.parse_bounded_integer_le sz)
(LowParse.Spec.BoundedInt.serialize_bounded_integer_le' sz)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"FStar.Classical.forall_intro",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le'",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.serializer_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind"
] | [] | false | false | true | false | false | let serialize_bounded_integer_le_correct (sz: integer_size)
: Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) =
| let prf (x: bounded_integer sz)
: Lemma
(let res = serialize_bounded_integer_le' sz x in
Seq.length res == (sz <: nat) /\
parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))) =
()
in
Classical.forall_intro prf | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.params_n | val params_n (a: S.frodo_alg) : x: size_t{v x == S.params_n a} | val params_n (a: S.frodo_alg) : x: size_t{v x == S.params_n a} | let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 21,
"start_col": 0,
"start_line": 16
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg
-> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.params_n a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.op_Equality",
"Prims.op_Modulus",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Frodo.Params.params_n"
] | [] | false | false | false | false | false | let params_n (a: S.frodo_alg) : x: size_t{v x == S.params_n a} =
| match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.frodo_gen_matrix | val frodo_gen_matrix:
a:S.frodo_gen_a{is_supported a}
-> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0}
-> seed:lbuffer uint8 16ul
-> a_matrix:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h a_matrix /\ disjoint seed a_matrix)
(ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\
as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) | val frodo_gen_matrix:
a:S.frodo_gen_a{is_supported a}
-> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0}
-> seed:lbuffer uint8 16ul
-> a_matrix:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h a_matrix /\ disjoint seed a_matrix)
(ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\
as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) | let frodo_gen_matrix a n seed a_matrix =
match a with
| S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 79,
"end_line": 131,
"start_col": 0,
"start_line": 129
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul)
inline_for_extraction noextract
let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a
inline_for_extraction noextract
let crypto_secretkeybytes (a:S.frodo_alg) =
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a
inline_for_extraction noextract
let crypto_ciphertextbytes (a:S.frodo_alg) =
ct1bytes_len a +! ct2bytes_len a
inline_for_extraction noextract
let frodo_shake_st (a:S.frodo_alg) =
inputByteLen:size_t
-> input:lbuffer uint8 inputByteLen
-> outputByteLen:size_t
-> output:lbuffer uint8 outputByteLen
-> Stack unit
(requires fun h ->
live h input /\ live h output /\ disjoint input output)
(ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\
as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen))
inline_for_extraction noextract
let frodo_shake (a:S.frodo_alg) : frodo_shake_st a =
match a with
| S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl
| S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl
inline_for_extraction noextract
let is_supported (a:S.frodo_gen_a) =
match a with
| S.SHAKE128 -> true
| S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *)
val frodo_gen_matrix:
a:S.frodo_gen_a{is_supported a}
-> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0}
-> seed:lbuffer uint8 16ul
-> a_matrix:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h a_matrix /\ disjoint seed a_matrix)
(ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\
as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported a} ->
n:
Lib.IntTypes.size_t
{ 0 < Lib.IntTypes.v n /\ Lib.IntTypes.v n * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t /\
Lib.IntTypes.v n <= Lib.IntTypes.maxint Lib.IntTypes.U16 /\ Lib.IntTypes.v n % 4 = 0 } ->
seed: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul ->
a_matrix: Hacl.Impl.Matrix.matrix_t n n
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.maxint",
"Lib.IntTypes.U16",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Matrix.matrix_t",
"Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x",
"Prims.unit"
] | [] | false | true | false | false | false | let frodo_gen_matrix a n seed a_matrix =
| match a with | S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.cdf_table1344 | val cdf_table1344:x: glbuffer uint16 7ul {witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} | val cdf_table1344:x: glbuffer uint16 7ul {witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} | let cdf_table1344 :x:glbuffer uint16 7ul{witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} =
createL_global S.cdf_list_1344 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 144,
"start_col": 0,
"start_line": 143
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul)
inline_for_extraction noextract
let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a
inline_for_extraction noextract
let crypto_secretkeybytes (a:S.frodo_alg) =
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a
inline_for_extraction noextract
let crypto_ciphertextbytes (a:S.frodo_alg) =
ct1bytes_len a +! ct2bytes_len a
inline_for_extraction noextract
let frodo_shake_st (a:S.frodo_alg) =
inputByteLen:size_t
-> input:lbuffer uint8 inputByteLen
-> outputByteLen:size_t
-> output:lbuffer uint8 outputByteLen
-> Stack unit
(requires fun h ->
live h input /\ live h output /\ disjoint input output)
(ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\
as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen))
inline_for_extraction noextract
let frodo_shake (a:S.frodo_alg) : frodo_shake_st a =
match a with
| S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl
| S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl
inline_for_extraction noextract
let is_supported (a:S.frodo_gen_a) =
match a with
| S.SHAKE128 -> true
| S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *)
val frodo_gen_matrix:
a:S.frodo_gen_a{is_supported a}
-> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0}
-> seed:lbuffer uint8 16ul
-> a_matrix:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h a_matrix /\ disjoint seed a_matrix)
(ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\
as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed))
[@CInline]
let frodo_gen_matrix a n seed a_matrix =
match a with
| S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix
(* | S.AES128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_aes n seed a_matrix *)
(** CDF tables *)
let cdf_table640 :x:glbuffer uint16 13ul{witnessed x (S.cdf_table S.Frodo640) /\ recallable x} =
createL_global S.cdf_list_640
let cdf_table976 :x:glbuffer uint16 11ul{witnessed x (S.cdf_table S.Frodo976) /\ recallable x} =
createL_global S.cdf_list_976 | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
(c:
Lib.Buffer.lbuffer_t Lib.Buffer.CONST
(Lib.IntTypes.int_t Lib.IntTypes.U16 Lib.IntTypes.SEC)
(7ul <: FStar.UInt32.t) {LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE})
{ Lib.Buffer.witnessed x (Spec.Frodo.Params.cdf_table Spec.Frodo.Params.Frodo1344) /\
Lib.Buffer.recallable x } | Prims.Tot | [
"total"
] | [] | [
"Lib.Buffer.createL_global",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Spec.Frodo.Params.cdf_list_1344",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"FStar.List.Tot.Base.length"
] | [] | false | false | false | false | false | let cdf_table1344:x: glbuffer uint16 7ul {witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} =
| createL_global S.cdf_list_1344 | false |
Pulse.Checker.Prover.fst | Pulse.Checker.Prover.unsolved_equiv_pst | val unsolved_equiv_pst
(#preamble: _)
(pst: prover_state preamble)
(unsolved': list vprop)
(d:
vprop_equiv (push_env pst.pg pst.uvs)
(list_as_vprop pst.unsolved)
(list_as_vprop unsolved'))
: prover_state preamble | val unsolved_equiv_pst
(#preamble: _)
(pst: prover_state preamble)
(unsolved': list vprop)
(d:
vprop_equiv (push_env pst.pg pst.uvs)
(list_as_vprop pst.unsolved)
(list_as_vprop unsolved'))
: prover_state preamble | let unsolved_equiv_pst (#preamble:_) (pst:prover_state preamble) (unsolved':list vprop)
(d:vprop_equiv (push_env pst.pg pst.uvs) (list_as_vprop pst.unsolved) (list_as_vprop unsolved'))
: prover_state preamble =
{ pst with unsolved = unsolved'; goals_inv = RU.magic () } | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 60,
"end_line": 56,
"start_col": 0,
"start_line": 53
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Prover
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Base
module RU = Pulse.RuntimeUtils
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Pprint = FStar.Stubs.Pprint
module Metatheory = Pulse.Typing.Metatheory
module PS = Pulse.Checker.Prover.Substs
module ElimExists = Pulse.Checker.Prover.ElimExists
module ElimPure = Pulse.Checker.Prover.ElimPure
module Match = Pulse.Checker.Prover.Match
module IntroExists = Pulse.Checker.Prover.IntroExists
module IntroPure = Pulse.Checker.Prover.IntroPure
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x
let elim_exists_and_pure (#g:env) (#ctxt:vprop)
(ctxt_typing:tot_typing g ctxt tm_vprop)
: T.Tac (g':env { env_extends g' g } &
ctxt':term &
tot_typing g' ctxt' tm_vprop &
continuation_elaborator g ctxt g' ctxt') =
let (| g1, ctxt1, d1, k1 |) = ElimExists.elim_exists ctxt_typing in
let (| g2, ctxt2, d2, k2 |) = ElimPure.elim_pure d1 in
(| g2, ctxt2, d2, k_elab_trans k1 k2 |) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Readback.fsti.checked",
"Pulse.PP.fst.checked",
"Pulse.Config.fsti.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Prover.Match.fsti.checked",
"Pulse.Checker.Prover.IntroPure.fsti.checked",
"Pulse.Checker.Prover.IntroExists.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Stubs.Pprint.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroPure",
"short_module": "IntroPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.IntroExists",
"short_module": "IntroExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "FStar.Stubs.Pprint",
"short_module": "Pprint"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"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.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover.Base",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
pst: Pulse.Checker.Prover.Base.prover_state preamble ->
unsolved': Prims.list Pulse.Syntax.Base.vprop ->
d:
Pulse.Typing.vprop_equiv (Pulse.Typing.Env.push_env (Mkprover_state?.pg pst)
(Mkprover_state?.uvs pst))
(Pulse.Typing.Combinators.list_as_vprop (Mkprover_state?.unsolved pst))
(Pulse.Typing.Combinators.list_as_vprop unsolved')
-> Pulse.Checker.Prover.Base.prover_state preamble | Prims.Tot | [
"total"
] | [] | [
"Pulse.Checker.Prover.Base.preamble",
"Pulse.Checker.Prover.Base.prover_state",
"Prims.list",
"Pulse.Syntax.Base.vprop",
"Pulse.Typing.vprop_equiv",
"Pulse.Typing.Env.push_env",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__pg",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__uvs",
"Pulse.Typing.Combinators.list_as_vprop",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__unsolved",
"Pulse.Checker.Prover.Base.Mkprover_state",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__remaining_ctxt",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__remaining_ctxt_frame_typing",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__ss",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__nts",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__solved",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__k",
"Pulse.RuntimeUtils.magic",
"Pulse.Checker.Prover.Base.__proj__Mkpreamble__item__goals",
"Pulse.Checker.Prover.Base.op_Star",
"Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__solved_inv"
] | [] | false | false | false | false | false | let unsolved_equiv_pst
(#preamble: _)
(pst: prover_state preamble)
(unsolved': list vprop)
(d:
vprop_equiv (push_env pst.pg pst.uvs)
(list_as_vprop pst.unsolved)
(list_as_vprop unsolved'))
: prover_state preamble =
| { pst with unsolved = unsolved'; goals_inv = RU.magic () } | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.cdf_table_len | val cdf_table_len (a: S.frodo_alg) : x: size_t{v x = S.cdf_table_len a} | val cdf_table_len (a: S.frodo_alg) : x: size_t{v x = S.cdf_table_len a} | let cdf_table_len (a:S.frodo_alg) : x:size_t{v x = S.cdf_table_len a} =
allow_inversion S.frodo_alg;
match a with
| S.Frodo64 | S.Frodo640 -> 13ul
| S.Frodo976 -> 11ul
| S.Frodo1344 -> 7ul | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 153,
"start_col": 0,
"start_line": 148
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul)
inline_for_extraction noextract
let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a
inline_for_extraction noextract
let crypto_secretkeybytes (a:S.frodo_alg) =
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a
inline_for_extraction noextract
let crypto_ciphertextbytes (a:S.frodo_alg) =
ct1bytes_len a +! ct2bytes_len a
inline_for_extraction noextract
let frodo_shake_st (a:S.frodo_alg) =
inputByteLen:size_t
-> input:lbuffer uint8 inputByteLen
-> outputByteLen:size_t
-> output:lbuffer uint8 outputByteLen
-> Stack unit
(requires fun h ->
live h input /\ live h output /\ disjoint input output)
(ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\
as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen))
inline_for_extraction noextract
let frodo_shake (a:S.frodo_alg) : frodo_shake_st a =
match a with
| S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl
| S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl
inline_for_extraction noextract
let is_supported (a:S.frodo_gen_a) =
match a with
| S.SHAKE128 -> true
| S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *)
val frodo_gen_matrix:
a:S.frodo_gen_a{is_supported a}
-> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0}
-> seed:lbuffer uint8 16ul
-> a_matrix:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h a_matrix /\ disjoint seed a_matrix)
(ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\
as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed))
[@CInline]
let frodo_gen_matrix a n seed a_matrix =
match a with
| S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix
(* | S.AES128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_aes n seed a_matrix *)
(** CDF tables *)
let cdf_table640 :x:glbuffer uint16 13ul{witnessed x (S.cdf_table S.Frodo640) /\ recallable x} =
createL_global S.cdf_list_640
let cdf_table976 :x:glbuffer uint16 11ul{witnessed x (S.cdf_table S.Frodo976) /\ recallable x} =
createL_global S.cdf_list_976
let cdf_table1344 :x:glbuffer uint16 7ul{witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} =
createL_global S.cdf_list_1344 | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Frodo.Params.frodo_alg
-> x: Lib.IntTypes.size_t{Lib.IntTypes.v x = Spec.Frodo.Params.cdf_table_len a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Frodo.Params.frodo_alg",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Prims.l_and",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Spec.Frodo.Params.cdf_table_len",
"Prims.unit",
"FStar.Pervasives.allow_inversion"
] | [] | false | false | false | false | false | let cdf_table_len (a: S.frodo_alg) : x: size_t{v x = S.cdf_table_len a} =
| allow_inversion S.frodo_alg;
match a with
| S.Frodo64 | S.Frodo640 -> 13ul
| S.Frodo976 -> 11ul
| S.Frodo1344 -> 7ul | false |
Hacl.Impl.Frodo.Params.fst | Hacl.Impl.Frodo.Params.cdf_table640 | val cdf_table640:x: glbuffer uint16 13ul {witnessed x (S.cdf_table S.Frodo640) /\ recallable x} | val cdf_table640:x: glbuffer uint16 13ul {witnessed x (S.cdf_table S.Frodo640) /\ recallable x} | let cdf_table640 :x:glbuffer uint16 13ul{witnessed x (S.cdf_table S.Frodo640) /\ recallable x} =
createL_global S.cdf_list_640 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 138,
"start_col": 0,
"start_line": 137
} | module Hacl.Impl.Frodo.Params
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
module S = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} =
match a with
| S.Frodo64 -> 64ul
| S.Frodo640 -> 640ul
| S.Frodo976 -> 976ul
| S.Frodo1344 -> 1344ul
inline_for_extraction noextract
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} =
match a with
| S.Frodo64 | S.Frodo640 -> 15ul
| S.Frodo976 | S.Frodo1344 -> 16ul
inline_for_extraction noextract
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} =
match a with
| S.Frodo64 | S.Frodo640 -> 2ul
| S.Frodo976 -> 3ul
| S.Frodo1344 -> 4ul
inline_for_extraction noextract
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} =
match a with
| S.Frodo64 | S.Frodo640 -> 16ul
| S.Frodo976 -> 24ul
| S.Frodo1344 -> 32ul
inline_for_extraction noextract
let params_nbar = 8ul
inline_for_extraction noextract
let bytes_seed_a = 16ul
inline_for_extraction noextract
let bytes_pkhash (a:S.frodo_alg) =
crypto_bytes a
inline_for_extraction noextract
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} =
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
inline_for_extraction noextract
let publicmatrixbytes_len (a:S.frodo_alg) =
params_logq a *! (params_n a *! params_nbar /. 8ul)
inline_for_extraction noextract
let secretmatrixbytes_len (a:S.frodo_alg) =
2ul *! params_n a *! params_nbar
inline_for_extraction noextract
let ct1bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_n a /. 8ul)
inline_for_extraction noextract
let ct2bytes_len (a:S.frodo_alg) =
params_logq a *! (params_nbar *! params_nbar /. 8ul)
inline_for_extraction noextract
let crypto_publickeybytes (a:S.frodo_alg) =
bytes_seed_a +! publicmatrixbytes_len a
inline_for_extraction noextract
let crypto_secretkeybytes (a:S.frodo_alg) =
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a
inline_for_extraction noextract
let crypto_ciphertextbytes (a:S.frodo_alg) =
ct1bytes_len a +! ct2bytes_len a
inline_for_extraction noextract
let frodo_shake_st (a:S.frodo_alg) =
inputByteLen:size_t
-> input:lbuffer uint8 inputByteLen
-> outputByteLen:size_t
-> output:lbuffer uint8 outputByteLen
-> Stack unit
(requires fun h ->
live h input /\ live h output /\ disjoint input output)
(ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\
as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen))
inline_for_extraction noextract
let frodo_shake (a:S.frodo_alg) : frodo_shake_st a =
match a with
| S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl
| S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl
inline_for_extraction noextract
let is_supported (a:S.frodo_gen_a) =
match a with
| S.SHAKE128 -> true
| S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *)
val frodo_gen_matrix:
a:S.frodo_gen_a{is_supported a}
-> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0}
-> seed:lbuffer uint8 16ul
-> a_matrix:matrix_t n n
-> Stack unit
(requires fun h ->
live h seed /\ live h a_matrix /\ disjoint seed a_matrix)
(ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\
as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed))
[@CInline]
let frodo_gen_matrix a n seed a_matrix =
match a with
| S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix
(* | S.AES128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_aes n seed a_matrix *)
(** CDF tables *) | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.SHA3.fst.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Gen.fst.checked",
"FStar.UInt32.fsti.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.Frodo.Params.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x:
(c:
Lib.Buffer.lbuffer_t Lib.Buffer.CONST
(Lib.IntTypes.int_t Lib.IntTypes.U16 Lib.IntTypes.SEC)
(13ul <: FStar.UInt32.t) {LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE})
{ Lib.Buffer.witnessed x (Spec.Frodo.Params.cdf_table Spec.Frodo.Params.Frodo640) /\
Lib.Buffer.recallable x } | Prims.Tot | [
"total"
] | [] | [
"Lib.Buffer.createL_global",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Spec.Frodo.Params.cdf_list_640",
"Lib.Buffer.glbuffer",
"Lib.IntTypes.size",
"FStar.Pervasives.normalize_term",
"Lib.IntTypes.size_nat",
"FStar.List.Tot.Base.length"
] | [] | false | false | false | false | false | let cdf_table640:x: glbuffer uint16 13ul {witnessed x (S.cdf_table S.Frodo640) /\ recallable x} =
| createL_global S.cdf_list_640 | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.