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
EverCrypt.DRBG.fsti
EverCrypt.DRBG.supported_alg
val supported_alg : Type0
let supported_alg = S.supported_alg
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 54, "start_col": 0, "start_line": 54 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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.HMAC_DRBG.supported_alg" ]
[]
false
false
false
true
true
let supported_alg =
S.supported_alg
false
Hacl.Impl.Lib.fst
Hacl.Impl.Lib.update_sub_f_carry
val update_sub_f_carry: #a:Type -> #b:Type -> #len:size_t -> h0:mem -> buf:lbuffer a len -> start:size_t -> n:size_t{v start + v n <= v len} -> spec:(mem -> GTot (b & Seq.lseq a (v n))) -> f:(unit -> Stack b (requires fun h -> h0 == h) (ensures fun _ r h1 -> (let b = gsub buf start n in modifies (loc b) h0 h1 /\ (let (c, res) = spec h0 in r == c /\ as_seq h1 b == res)))) -> Stack b (requires fun h -> h0 == h /\ live h buf) (ensures fun h0 r h1 -> modifies (loc buf) h0 h1 /\ (let (c, res) = spec h0 in r == c /\ as_seq h1 buf == LSeq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) res))
val update_sub_f_carry: #a:Type -> #b:Type -> #len:size_t -> h0:mem -> buf:lbuffer a len -> start:size_t -> n:size_t{v start + v n <= v len} -> spec:(mem -> GTot (b & Seq.lseq a (v n))) -> f:(unit -> Stack b (requires fun h -> h0 == h) (ensures fun _ r h1 -> (let b = gsub buf start n in modifies (loc b) h0 h1 /\ (let (c, res) = spec h0 in r == c /\ as_seq h1 b == res)))) -> Stack b (requires fun h -> h0 == h /\ live h buf) (ensures fun h0 r h1 -> modifies (loc buf) h0 h1 /\ (let (c, res) = spec h0 in r == c /\ as_seq h1 buf == LSeq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) res))
let update_sub_f_carry #a #b #len h0 buf start n spec f = let tmp = sub buf start n in let h0 = ST.get () in let r = f () in let h1 = ST.get () in assert (v (len -! (start +! n)) == v len - v (start +! n)); B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1; B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 buf) (v start) (v n) (snd (spec h0)) (as_seq h1 buf); r
{ "file_name": "code/bignum/Hacl.Impl.Lib.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 218, "start_col": 0, "start_line": 209 }
module Hacl.Impl.Lib open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators module S = Hacl.Spec.Lib #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let fill_elems_st = #t:Type0 -> #a:Type0 -> h0:mem -> n:size_t -> output:lbuffer t n -> refl:(mem -> i:size_nat{i <= v n} -> GTot a) -> footprint:(i:size_nat{i <= v n} -> GTot (l:B.loc{B.loc_disjoint l (loc output) /\ B.address_liveness_insensitive_locs `B.loc_includes` l})) -> spec:(mem -> GTot (i:size_nat{i < v n} -> a -> a & t)) -> impl:(i:size_t{v i < v n} -> Stack unit (requires fun h -> modifies (footprint (v i) |+| loc (gsub output 0ul i)) h0 h) (ensures fun h1 _ h2 -> (let block1 = gsub output i 1ul in let c, e = spec h0 (v i) (refl h1 (v i)) in refl h2 (v i + 1) == c /\ LSeq.index (as_seq h2 block1) 0 == e /\ footprint (v i + 1) `B.loc_includes` footprint (v i) /\ modifies (footprint (v i + 1) |+| (loc block1)) h1 h2))) -> Stack unit (requires fun h -> h0 == h /\ live h output) (ensures fun _ _ h1 -> modifies (footprint (v n) |+| loc output) h0 h1 /\ (let s, o = S.generate_elems (v n) (v n) (spec h0) (refl h0 0) in refl h1 (v n) == s /\ as_seq #_ #t h1 output == o)) inline_for_extraction noextract val fill_elems : fill_elems_st let fill_elems #t #a h0 n output refl footprint spec impl = [@inline_let] let refl' h (i:nat{i <= v n}) : GTot (S.generate_elem_a t a (v n) i) = refl h i, as_seq h (gsub output 0ul (size i)) in [@inline_let] let footprint' i = footprint i |+| loc (gsub output 0ul (size i)) in [@inline_let] let spec' h0 = S.generate_elem_f (v n) (spec h0) in let h0 = ST.get () in loop h0 n (S.generate_elem_a t a (v n)) refl' footprint' spec' (fun i -> Loops.unfold_repeat_gen (v n) (S.generate_elem_a t a (v n)) (spec' h0) (refl' h0 0) (v i); impl i; let h = ST.get() in FStar.Seq.lemma_split (as_seq h (gsub output 0ul (i +! 1ul))) (v i) ); let h1 = ST.get () in assert (refl' h1 (v n) == Loops.repeat_gen (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl' h0 0)) inline_for_extraction noextract val fill_blocks4: #t:Type0 -> #a:Type0 -> h0:mem -> n4:size_t{4 * v n4 <= max_size_t} -> output:lbuffer t (4ul *! n4) -> refl:(mem -> i:size_nat{i <= 4 * v n4} -> GTot a) -> footprint:(i:size_nat{i <= 4 * v n4} -> GTot (l:B.loc{B.loc_disjoint l (loc output) /\ B.address_liveness_insensitive_locs `B.loc_includes` l})) -> spec:(mem -> GTot (i:size_nat{i < 4 * v n4} -> a -> a & t)) -> impl:(i:size_t{v i < 4 * v n4} -> Stack unit (requires fun h -> modifies (footprint (v i) |+| loc (gsub output 0ul i)) h0 h) (ensures fun h1 _ h2 -> (let block1 = gsub output i 1ul in let c, e = spec h0 (v i) (refl h1 (v i)) in refl h2 (v i + 1) == c /\ LSeq.index (as_seq h2 block1) 0 == e /\ footprint (v i + 1) `B.loc_includes` footprint (v i) /\ modifies (footprint (v i + 1) |+| (loc block1)) h1 h2))) -> Stack unit (requires fun h -> h0 == h /\ live h output) (ensures fun _ _ h1 -> modifies (footprint (4 * v n4) |+| loc output) h0 h1 /\ (let s, o = LSeq.generate_blocks 4 (v n4) (v n4) (Loops.fixed_a a) (S.generate_blocks4_f #t #a (v n4) (spec h0)) (refl h0 0) in refl h1 (4 * v n4) == s /\ as_seq #_ #t h1 output == o)) let fill_blocks4 #t #a h0 n4 output refl footprint spec impl = fill_blocks h0 4ul n4 output (Loops.fixed_a a) (fun h i -> refl h (4 * i)) (fun i -> footprint (4 * i)) (fun h0 -> S.generate_blocks4_f #t #a (v n4) (spec h0)) (fun i -> let h1 = ST.get () in impl (4ul *! i); impl (4ul *! i +! 1ul); impl (4ul *! i +! 2ul); impl (4ul *! i +! 3ul); let h2 = ST.get () in assert ( let c0, e0 = spec h0 (4 * v i) (refl h1 (4 * v i)) in let c1, e1 = spec h0 (4 * v i + 1) c0 in let c2, e2 = spec h0 (4 * v i + 2) c1 in let c3, e3 = spec h0 (4 * v i + 3) c2 in let res = LSeq.create4 e0 e1 e2 e3 in LSeq.create4_lemma e0 e1 e2 e3; let res1 = LSeq.sub (as_seq h2 output) (4 * v i) 4 in refl h2 (4 * v i + 4) == c3 /\ (LSeq.eq_intro res res1; res1 `LSeq.equal` res)) ) inline_for_extraction noextract val fill_elems4: fill_elems_st let fill_elems4 #t #a h0 n output refl footprint spec impl = [@inline_let] let k = n /. 4ul in let tmp = sub output 0ul (4ul *! k) in fill_blocks4 #t #a h0 k tmp refl footprint spec (fun i -> impl i); let h1 = ST.get () in assert (4 * v k + v (n -! 4ul *! k) = v n); B.modifies_buffer_elim (B.gsub #t output (4ul *! k) (n -! 4ul *! k)) (footprint (4 * v k) |+| loc tmp) h0 h1; assert (modifies (footprint (4 * v k) |+| loc (gsub output 0ul (4ul *! k))) h0 h1); let inv (h:mem) (i:nat{4 * v k <= i /\ i <= v n}) = modifies (footprint i |+| loc (gsub output 0ul (size i))) h0 h /\ (let (c, res) = Loops.repeat_right (v n / 4 * 4) i (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl h1 (4 * v k), as_seq h1 (gsub output 0ul (4ul *! k))) in refl h i == c /\ as_seq h (gsub output 0ul (size i)) == res) in Loops.eq_repeat_right (v n / 4 * 4) (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl h1 (4 * v k), as_seq h1 (gsub output 0ul (4ul *! k))); Lib.Loops.for (k *! 4ul) n inv (fun i -> impl i; let h = ST.get () in assert (v (i +! 1ul) = v i + 1); FStar.Seq.lemma_split (as_seq h (gsub output 0ul (i +! 1ul))) (v i); Loops.unfold_repeat_right (v n / 4 * 4) (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl h1 (4 * v k), as_seq h1 (gsub output 0ul (4ul *! k))) (v i) ); S.lemma_generate_elems4 (v n) (v n) (spec h0) (refl h0 0) inline_for_extraction noextract val lemma_eq_disjoint: #a1:Type -> #a2:Type -> #a3:Type -> clen1:size_t -> clen2:size_t -> clen3:size_t -> b1:lbuffer a1 clen1 -> b2:lbuffer a2 clen2 -> b3:lbuffer a3 clen3 -> n:size_t{v n < v clen2 /\ v n < v clen1} -> h0:mem -> h1:mem -> Lemma (requires live h0 b1 /\ live h0 b2 /\ live h0 b3 /\ eq_or_disjoint b1 b2 /\ disjoint b1 b3 /\ disjoint b2 b3 /\ modifies (loc (gsub b1 0ul n) |+| loc b3) h0 h1) (ensures (let b2s = gsub b2 n (clen2 -! n) in as_seq h0 b2s == as_seq h1 b2s /\ Seq.index (as_seq h0 b2) (v n) == Seq.index (as_seq h1 b2) (v n))) let lemma_eq_disjoint #a1 #a2 #a3 clen1 clen2 clen3 b1 b2 b3 n h0 h1 = let b1s = gsub b1 0ul n in let b2s = gsub b2 0ul n in assert (modifies (loc b1s |+| loc b3) h0 h1); assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2) (as_seq h1 b2)); assert (disjoint b1 b2 ==> Seq.equal (as_seq h0 b2s) (as_seq h1 b2s)); assert (Seq.index (as_seq h1 b2) (v n) == Seq.index (as_seq h1 (gsub b2 n (clen2 -! n))) 0) inline_for_extraction noextract val update_sub_f_carry: #a:Type -> #b:Type -> #len:size_t -> h0:mem -> buf:lbuffer a len -> start:size_t -> n:size_t{v start + v n <= v len} -> spec:(mem -> GTot (b & Seq.lseq a (v n))) -> f:(unit -> Stack b (requires fun h -> h0 == h) (ensures fun _ r h1 -> (let b = gsub buf start n in modifies (loc b) h0 h1 /\ (let (c, res) = spec h0 in r == c /\ as_seq h1 b == res)))) -> Stack b (requires fun h -> h0 == h /\ live h buf) (ensures fun h0 r h1 -> modifies (loc buf) h0 h1 /\ (let (c, res) = spec h0 in r == c /\ as_seq h1 buf == LSeq.update_sub #a #(v len) (as_seq h0 buf) (v start) (v n) res))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Lib.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Lib.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Lib", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": 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
h0: FStar.Monotonic.HyperStack.mem -> buf: Lib.Buffer.lbuffer a len -> start: Lib.IntTypes.size_t -> n: Lib.IntTypes.size_t{Lib.IntTypes.v start + Lib.IntTypes.v n <= Lib.IntTypes.v len} -> spec: (_: FStar.Monotonic.HyperStack.mem -> Prims.GTot (b * FStar.Seq.Properties.lseq a (Lib.IntTypes.v n))) -> f: (_: Prims.unit -> FStar.HyperStack.ST.Stack b) -> FStar.HyperStack.ST.Stack b
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.IntTypes.size_t", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.lbuffer", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.lseq", "Prims.unit", "Prims.eq2", "Prims.l_and", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Buffer.MUT", "FStar.Seq.Base.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.Buffer.as_seq", "Prims.logical", "Lib.Buffer.lbuffer_t", "Lib.Buffer.gsub", "Lib.Sequence.lemma_update_sub", "FStar.Pervasives.Native.snd", "LowStar.Monotonic.Buffer.modifies_buffer_elim", "LowStar.Buffer.trivial_preorder", "LowStar.Buffer.gsub", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Subtraction_Bang", "FStar.UInt32.__uint_to_t", "Prims._assert", "Prims.int", "Prims.op_Subtraction", "FStar.HyperStack.ST.get", "Lib.Buffer.sub" ]
[]
false
true
false
false
false
let update_sub_f_carry #a #b #len h0 buf start n spec f =
let tmp = sub buf start n in let h0 = ST.get () in let r = f () in let h1 = ST.get () in assert (v (len -! (start +! n)) == v len - v (start +! n)); B.modifies_buffer_elim (B.gsub #a buf 0ul start) (loc tmp) h0 h1; B.modifies_buffer_elim (B.gsub #a buf (start +! n) (len -! (start +! n))) (loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 buf) (v start) (v n) (snd (spec h0)) (as_seq h1 buf); r
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.state
val state : a: EverCrypt.DRBG.supported_alg -> Type0
let state a = B.pointer (state_s a)
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 97, "start_col": 0, "start_line": 97 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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: EverCrypt.DRBG.supported_alg -> Type0
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "LowStar.Buffer.pointer", "EverCrypt.DRBG.state_s" ]
[]
false
false
false
true
true
let state a =
B.pointer (state_s a)
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.freeable
val freeable : st: EverCrypt.DRBG.state a -> h: FStar.Monotonic.HyperStack.mem -> Prims.logical
let freeable (#a:supported_alg) (st:state a) (h:HS.mem) = B.freeable st /\ freeable_s (B.deref h st)
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 104, "start_col": 0, "start_line": 103 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0 inline_for_extraction noextract let state a = B.pointer (state_s a) inline_for_extraction noextract val freeable_s: #a:supported_alg -> st:state_s a -> Type0
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
st: EverCrypt.DRBG.state a -> h: FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "EverCrypt.DRBG.state", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Monotonic.Buffer.freeable", "EverCrypt.DRBG.state_s", "LowStar.Buffer.trivial_preorder", "EverCrypt.DRBG.freeable_s", "LowStar.Monotonic.Buffer.deref", "Prims.logical" ]
[]
false
false
false
false
true
let freeable (#a: supported_alg) (st: state a) (h: HS.mem) =
B.freeable st /\ freeable_s (B.deref h st)
false
LowParse.BitFields.fst
LowParse.BitFields.get_bitfield8
val get_bitfield8 (x: U8.t) (lo: nat) (hi: nat{lo <= hi /\ hi <= 8}) : Tot (y: U8.t{U8.v y == get_bitfield (U8.v x) lo hi})
val get_bitfield8 (x: U8.t) (lo: nat) (hi: nat{lo <= hi /\ hi <= 8}) : Tot (y: U8.t{U8.v y == get_bitfield (U8.v x) lo hi})
let get_bitfield8 (x: U8.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 8}) : Tot (y: U8.t { U8.v y == get_bitfield (U8.v x) lo hi }) = if lo = hi then 0uy else get_bitfield_gen8 x (U32.uint_to_t lo) (U32.uint_to_t hi)
{ "file_name": "src/lowparse/LowParse.BitFields.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 59, "end_line": 1160, "start_col": 0, "start_line": 1156 }
module LowParse.BitFields module U = FStar.UInt module M = LowParse.Math open FStar.Mul inline_for_extraction let bitfield_mask (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Tot (U.uint_t tot) = [@inline_let] let _ = M.pow2_le_compat tot hi; M.pow2_plus (hi - lo) lo in normalize_term ((pow2 (hi - lo) - 1) * pow2 lo) let bitfield_mask_eq (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Lemma ( 0 <= pow2 (hi - lo) - 1 /\ pow2 (hi - lo) - 1 < pow2 tot /\ bitfield_mask tot lo hi == U.shift_left #tot (pow2 (hi - lo) - 1) lo ) = M.pow2_le_compat tot (hi - lo); U.shift_left_value_lemma #tot (pow2 (hi - lo) - 1) lo; M.pow2_le_compat tot hi; M.pow2_plus (hi - lo) lo; M.lemma_mult_nat (pow2 (hi - lo) - 1) (pow2 lo); M.lemma_mult_lt' (pow2 lo) (pow2 (hi - lo) - 1) (pow2 (hi - lo)); M.swap_mul (pow2 (hi - lo)) (pow2 lo); M.swap_mul (pow2 (hi - lo) - 1) (pow2 lo); M.modulo_lemma ((pow2 (hi - lo) - 1) * pow2 lo) (pow2 tot) (* Cf. U.index_to_vec_ones; WHY WHY WHY is it private? *) val nth_pow2_minus_one' : #n:pos -> m:nat{m <= n} -> i:nat{i < n} -> Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (i < n - m ==> U.nth #n (pow2 m - 1) i == false) /\ (n - m <= i ==> U.nth #n (pow2 m - 1) i == true))) let rec nth_pow2_minus_one' #n m i = let a = pow2 m - 1 in M.pow2_le_compat n m; if m = 0 then U.one_to_vec_lemma #n i else if m = n then U.ones_to_vec_lemma #n i else if i = n - 1 then () else nth_pow2_minus_one' #(n - 1) (m - 1) i (* Rephrasing with a more natural nth *) let nth (#n: pos) (a: U.uint_t n) (i: nat {i < n}) : Tot bool = U.nth a (n - 1 - i) let eq_nth (#n: pos) (a: U.uint_t n) (b: U.uint_t n) (f: ( (i: nat { i < n }) -> Lemma (nth a i == nth b i) )) : Lemma (a == b) = let g (i: nat { i < n }) : Lemma (U.nth a i == U.nth b i) = f (n - 1 - i) in Classical.forall_intro g; U.nth_lemma a b let nth_pow2_minus_one (#n:pos) (m:nat{m <= n}) (i:nat{i < n}) : Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (nth #n (pow2 m - 1) i == (i < m)))) = nth_pow2_minus_one' #n m (n - 1 - i) let nth_shift_left (#n: pos) (a: U.uint_t n) (s: nat) (i: nat {i < n}) : Lemma (nth (U.shift_left a s) i == (s <= i && nth a (i - s))) = () let nth_shift_right (#n: pos) (a: U.uint_t n) (s: nat) (i: nat {i < n}) : Lemma (nth (U.shift_right a s) i == (i + s < n && nth a (i + s))) = () let nth_bitfield_mask (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (i: nat {i < tot}) : Lemma (nth (bitfield_mask tot lo hi) i == (lo <= i && i < hi)) = bitfield_mask_eq tot lo hi; nth_shift_left #tot (pow2 (hi - lo) - 1) lo i; if i < lo then () else begin nth_pow2_minus_one #tot (hi - lo) (i - lo) end let get_bitfield_raw (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Tot (U.uint_t tot) = (x `U.logand` bitfield_mask tot lo hi) `U.shift_right` lo let nth_logand (#n: pos) (a b: U.uint_t n) (i: nat {i < n}) : Lemma (nth (a `U.logand` b) i == (nth a i && nth b i)) = () let nth_logor (#n: pos) (a b: U.uint_t n) (i: nat {i < n}) : Lemma (nth (a `U.logor` b) i == (nth a i || nth b i)) = () let nth_lognot (#n: pos) (a: U.uint_t n) (i: nat {i < n}) : Lemma (nth (U.lognot a) i == not (nth a i)) = () let nth_get_bitfield_raw (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) (i: nat {i < tot}) : Lemma (nth (get_bitfield_raw x lo hi) i == (i < hi - lo && nth x (i + lo))) = nth_shift_right (x `U.logand` bitfield_mask tot lo hi) lo i; if i + lo < tot then begin nth_logand x (bitfield_mask tot lo hi) (i + lo); nth_bitfield_mask tot lo hi (i + lo) end else () let get_bitfield_raw_eq_logand_pow2_hi_lo_minus_one (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Lemma (let y = get_bitfield_raw x lo hi in pow2 (hi - lo) - 1 < pow2 tot /\ y == y `U.logand` (pow2 (hi - lo) - 1) ) = nth_pow2_minus_one #tot (hi - lo) 0; let y = get_bitfield_raw x lo hi in eq_nth y (y `U.logand` (pow2 (hi - lo) - 1)) (fun i -> nth_get_bitfield_raw x lo hi i; nth_pow2_minus_one #tot (hi - lo) i; nth_logand y (pow2 (hi - lo) - 1) i ) #push-options "--z3rlimit 16" let logand_mask (#n: pos) (a: U.uint_t n) (m: nat {m <= n}) : Lemma (pow2 m <= pow2 n /\ U.logand a (pow2 m - 1) == a % pow2 m) = M.pow2_le_compat n m; if m = 0 then begin U.logand_lemma_1 a end else if m = n then begin U.logand_lemma_2 a; M.modulo_lemma a (pow2 m) end else begin U.logand_mask a m end #pop-options let nth_le_pow2_m (#n: pos) (a: U.uint_t n) (m: nat {m <= n}) (i: nat {i < n}) : Lemma (requires (a < pow2 m /\ m <= i)) (ensures (nth a i == false)) = logand_mask a m; M.modulo_lemma a (pow2 m); nth_pow2_minus_one #n m i; nth_logand a (pow2 m - 1) i let get_bitfield_raw_bounded (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Lemma (get_bitfield_raw x lo hi < pow2 (hi - lo)) = get_bitfield_raw_eq_logand_pow2_hi_lo_minus_one x lo hi; logand_mask (get_bitfield_raw x lo hi) (hi - lo); M.lemma_mod_lt x (pow2 (hi - lo)) let get_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Tot (ubitfield tot (hi - lo)) = get_bitfield_raw_bounded x lo hi; get_bitfield_raw x lo hi let nth_get_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) (i: nat {i < tot}) : Lemma (nth (get_bitfield x lo hi) i == (i < hi - lo && nth x (i + lo))) = nth_get_bitfield_raw x lo hi i let get_bitfield_logor (#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Lemma (get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi) = eq_nth (get_bitfield (x `U.logor` y) lo hi) (get_bitfield x lo hi `U.logor` get_bitfield y lo hi) (fun i -> nth_get_bitfield (x `U.logor` y) lo hi i; nth_get_bitfield x lo hi i; nth_get_bitfield y lo hi i ) let get_bitfield_logxor (#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Lemma (get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi) = eq_nth (get_bitfield (x `U.logxor` y) lo hi) (get_bitfield x lo hi `U.logxor` get_bitfield y lo hi) (fun i -> nth_get_bitfield (x `U.logxor` y) lo hi i; nth_get_bitfield x lo hi i; nth_get_bitfield y lo hi i ) #push-options "--z3rlimit 16" let logor_disjoint (#n: pos) (a: U.uint_t n) (b: U.uint_t n) (m: nat {m <= n}) : Lemma (requires ( a % pow2 m == 0 /\ b < pow2 m )) (ensures (U.logor #n a b == a + b)) = if m = 0 then U.logor_lemma_1 a else if m = n then begin M.modulo_lemma a (pow2 n); U.logor_commutative a b; U.logor_lemma_1 b end else U.logor_disjoint a b m #pop-options let bitfield_mask_mod_pow2_lo (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (m: nat {m <= lo}) : Lemma (bitfield_mask tot lo hi % pow2 m == 0) = M.pow2_multiplication_modulo_lemma_1 (pow2 (hi - lo) - 1) m lo let bitfield_mask_lt_pow2_hi (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Lemma (bitfield_mask tot lo hi < pow2 hi) = M.pow2_le_compat tot hi; M.pow2_plus (hi - lo) lo inline_for_extraction let not_bitfield_mask (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Tot (x: U.uint_t tot {x == U.lognot (bitfield_mask tot lo hi)}) = [@inline_let] let a = bitfield_mask tot hi tot in [@inline_let] let b = bitfield_mask tot 0 lo in [@inline_let] let _ = bitfield_mask_mod_pow2_lo tot hi tot lo; bitfield_mask_lt_pow2_hi tot 0 lo; logor_disjoint a b lo; eq_nth (a `U.logor` b) (U.lognot (bitfield_mask tot lo hi)) (fun i -> nth_bitfield_mask tot hi tot i; nth_bitfield_mask tot 0 lo i; nth_bitfield_mask tot lo hi i ) in normalize_term (a + b) let nth_not_bitfield_mask (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (i: nat {i < tot}) : Lemma (nth (not_bitfield_mask tot lo hi) i == (i < lo || hi <= i)) = nth_lognot (bitfield_mask tot lo hi) i; nth_bitfield_mask tot lo hi i let set_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) : Tot (U.uint_t tot) = (x `U.logand` not_bitfield_mask tot lo hi) `U.logor` (v `U.shift_left` lo) let nth_set_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) (i: nat {i < tot}) : Lemma (nth (set_bitfield x lo hi v) i == (if lo <= i && i < hi then nth v (i - lo) else nth x i)) = let y = nth (set_bitfield x lo hi v) i in nth_logor (x `U.logand` not_bitfield_mask tot lo hi) (v `U.shift_left` lo) i; assert (y == (nth (x `U.logand` not_bitfield_mask tot lo hi) i || nth (v `U.shift_left` lo) i)); nth_logand x (not_bitfield_mask tot lo hi) i; assert (y == ((nth x i && nth (not_bitfield_mask tot lo hi) i) || nth (v `U.shift_left` lo) i)); nth_not_bitfield_mask tot lo hi i; assert (y == ((nth x i && (i < lo || hi <= i)) || nth (v `U.shift_left` lo) i)); nth_shift_left v lo i; assert (y == ((nth x i && (i < lo || hi <= i)) || (lo <= i && nth v (i - lo)))); if (lo <= i && i < hi) then assert (y == nth v (i - lo)) else if (i < hi) then assert (y == nth x i) else begin nth_le_pow2_m v (hi - lo) (i - lo); assert (y == nth x i) end; assert (y == (if lo <= i && i < hi then nth v (i - lo) else nth x i)) #push-options "--z3rlimit 32" let get_bitfield_set_bitfield_same (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) : Lemma (get_bitfield (set_bitfield x lo hi v) lo hi == v) = eq_nth (get_bitfield (set_bitfield x lo hi v) lo hi) v (fun i -> nth_get_bitfield (set_bitfield x lo hi v) lo hi i; if i < hi - lo then begin nth_set_bitfield x lo hi v (i + lo) end else nth_le_pow2_m v (hi - lo) i ) #pop-options let get_bitfield_set_bitfield_other (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) (lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) : Lemma (requires (hi' <= lo \/ hi <= lo')) (ensures (get_bitfield (set_bitfield x lo hi v) lo' hi' == get_bitfield x lo' hi')) = eq_nth (get_bitfield (set_bitfield x lo hi v) lo' hi') (get_bitfield x lo' hi') (fun i -> nth_get_bitfield (set_bitfield x lo hi v) lo' hi' i; nth_get_bitfield x lo' hi' i; if i < hi' - lo' then begin nth_set_bitfield x lo hi v (i + lo') end ) let set_bitfield_set_bitfield_same_gen (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) (lo' : nat) (hi' : nat { lo' <= lo /\ hi <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo')) : Lemma (ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield x lo' hi' v')) = eq_nth (set_bitfield (set_bitfield x lo hi v) lo' hi' v') (set_bitfield x lo' hi' v') (fun i -> nth_set_bitfield (set_bitfield x lo hi v) lo' hi' v' i; nth_set_bitfield x lo hi v i; nth_set_bitfield x lo' hi' v' i ) let set_bitfield_set_bitfield_other (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) (lo' : nat) (hi' : nat { lo' <= hi' /\ hi' <= tot }) (v' : ubitfield tot (hi' - lo')) : Lemma (requires (hi' <= lo \/ hi <= lo')) (ensures (set_bitfield (set_bitfield x lo hi v) lo' hi' v' == set_bitfield (set_bitfield x lo' hi' v') lo hi v)) = eq_nth (set_bitfield (set_bitfield x lo hi v) lo' hi' v') (set_bitfield (set_bitfield x lo' hi' v') lo hi v) (fun i -> nth_set_bitfield (set_bitfield x lo hi v) lo' hi' v' i; nth_set_bitfield x lo hi v i; nth_set_bitfield (set_bitfield x lo' hi' v') lo hi v i; nth_set_bitfield x lo' hi' v' i ) let set_bitfield_full (#tot: pos) (x: U.uint_t tot) (y: ubitfield tot tot) : Lemma (set_bitfield x 0 tot y == y) = eq_nth (set_bitfield x 0 tot y) y (fun i -> nth_set_bitfield x 0 tot y i ) let set_bitfield_empty (#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) (y: ubitfield tot 0) : Lemma (set_bitfield x i i y == x) = eq_nth (set_bitfield x i i y) x (fun j -> nth_set_bitfield x i i y j ) let nth_zero (tot: pos) (i: nat {i < tot}) : Lemma (nth #tot 0 i == false) = U.zero_nth_lemma #tot i let get_bitfield_zero (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Lemma (get_bitfield #tot 0 lo hi == 0) = eq_nth (get_bitfield #tot 0 lo hi) 0 (fun i -> nth_zero tot i; nth_get_bitfield #tot 0 lo hi i; if i < hi - lo then nth_zero tot (i + lo) ) let get_bitfield_full (#tot: pos) (x: U.uint_t tot) : Lemma (get_bitfield x 0 tot == x) = eq_nth (get_bitfield x 0 tot) x (fun i -> nth_get_bitfield x 0 tot i ) let get_bitfield_empty (#tot: pos) (x: U.uint_t tot) (i: nat { i <= tot }) : Lemma (get_bitfield x i i == 0) = eq_nth (get_bitfield x i i) 0 (fun j -> nth_get_bitfield x i i j; nth_zero tot j ) let lt_pow2_get_bitfield_hi (#tot: pos) (x: U.uint_t tot) (mi: nat {mi <= tot}) : Lemma (requires (x < pow2 mi)) (ensures (get_bitfield x mi tot == 0)) = if mi = 0 then get_bitfield_zero tot mi tot else if mi < tot then begin M.modulo_lemma x (pow2 mi); U.logand_mask x mi; eq_nth (get_bitfield x mi tot) 0 (fun i -> nth_zero tot i; nth_get_bitfield x mi tot i; nth_get_bitfield (x `U.logand` (pow2 mi - 1)) mi tot i; nth_pow2_minus_one #tot mi i ) end let get_bitfield_hi_lt_pow2 (#tot: pos) (x: U.uint_t tot) (mi: nat {mi <= tot}) : Lemma (requires (get_bitfield x mi tot == 0)) (ensures (x < pow2 mi)) = if mi = 0 then get_bitfield_full x else if mi < tot then begin M.pow2_le_compat tot mi; eq_nth x (x `U.logand` (pow2 mi - 1)) (fun i -> nth_pow2_minus_one #tot mi i; if mi <= i then begin nth_get_bitfield x mi tot (i - mi); nth_zero tot (i - mi) end ); U.logand_mask x mi; M.lemma_mod_lt x (pow2 mi) end let get_bitfield_get_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (lo': nat) (hi': nat { lo' <= hi' /\ hi' <= hi - lo }) : Lemma (get_bitfield (get_bitfield x lo hi) lo' hi' == get_bitfield x (lo + lo') (lo + hi')) = eq_nth (get_bitfield (get_bitfield x lo hi) lo' hi') (get_bitfield x (lo + lo') (lo + hi')) (fun i -> nth_get_bitfield (get_bitfield x lo hi) lo' hi' i; nth_get_bitfield x (lo + lo') (lo + hi') i ; if i < hi' - lo' then nth_get_bitfield x lo hi (i + lo') ) #push-options "--z3rlimit_factor 2" let get_bitfield_zero_inner (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (lo': nat { lo <= lo' }) (hi': nat { lo' <= hi' /\ hi' <= hi }) : Lemma (ensures (get_bitfield x lo hi == 0 ==> get_bitfield x lo' hi' == 0)) = let f () : Lemma (requires (get_bitfield x lo hi == 0)) (ensures (get_bitfield x lo' hi' == 0)) = eq_nth (get_bitfield x lo' hi') 0 (fun i -> nth_get_bitfield x lo' hi' i; nth_zero tot i; if (i < hi' - lo') then begin nth_get_bitfield x lo hi (i + lo' - lo); nth_zero tot (i + lo'); nth_zero tot (i + lo' - lo) end ) in Classical.move_requires f () #pop-options #push-options "--z3rlimit 32" let bitfield_is_zero (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Lemma (get_bitfield x lo hi == 0 <==> x `U.logand` bitfield_mask tot lo hi == 0) = let y = x `U.logand` bitfield_mask tot lo hi in let z = get_bitfield x lo hi in let f () : Lemma (requires (y == 0)) (ensures (z == 0)) = eq_nth z 0 (fun i -> nth_zero tot i; nth_logand x (bitfield_mask tot lo hi) i; nth_bitfield_mask tot lo hi i; nth_get_bitfield x lo hi i; if i < hi - lo then nth_zero tot (i + lo) ) in let g () : Lemma (requires (z == 0)) (ensures (y == 0)) = eq_nth y 0 (fun i -> nth_zero tot i; nth_logand x (bitfield_mask tot lo hi) i; nth_bitfield_mask tot lo hi i; if lo <= i && i < hi then begin nth_get_bitfield x lo hi (i - lo); nth_zero tot (i - lo) end ) in Classical.move_requires f (); Classical.move_requires g () #pop-options #push-options "--z3rlimit 16" let bitfield_eq_shift (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) : Lemma (get_bitfield x lo hi == v <==> x `U.logand` bitfield_mask tot lo hi == v `U.shift_left` lo) = let y = x `U.logand` bitfield_mask tot lo hi in let z = get_bitfield x lo hi in let w = v `U.shift_left` lo in let f () : Lemma (requires (y == w)) (ensures (z == v)) = eq_nth z v (fun i -> nth_logand x (bitfield_mask tot lo hi) i; nth_bitfield_mask tot lo hi i; nth_get_bitfield x lo hi i; if hi - lo <= i then nth_le_pow2_m v (hi - lo) i else nth_shift_left v lo (i + lo) ) in let g () : Lemma (requires (z == v)) (ensures (y == w)) = eq_nth y w (fun i -> nth_logand x (bitfield_mask tot lo hi) i; nth_bitfield_mask tot lo hi i; nth_shift_left v lo i; if hi <= i then nth_le_pow2_m v (hi - lo) (i - lo) else if lo <= i then begin nth_get_bitfield x lo hi (i - lo) end ) in Classical.move_requires f (); Classical.move_requires g () #pop-options #push-options "--z3rlimit 16" let set_bitfield_get_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Lemma (set_bitfield x lo hi (get_bitfield x lo hi) == x) = eq_nth (set_bitfield x lo hi (get_bitfield x lo hi)) x (fun i -> nth_set_bitfield x lo hi (get_bitfield x lo hi) i; if lo <= i && i < hi then nth_get_bitfield x lo hi (i - lo) ) #pop-options #push-options "--z3rlimit 16" let get_bitfield_partition_2_gen (#tot: pos) (lo: nat) (mi: nat) (hi: nat { lo <= mi /\ mi <= hi /\ hi <= tot }) (x y: U.uint_t tot) : Lemma (requires ( get_bitfield x lo mi == get_bitfield y lo mi /\ get_bitfield x mi hi == get_bitfield y mi hi )) (ensures ( get_bitfield x lo hi == get_bitfield y lo hi )) = eq_nth (get_bitfield x lo hi) (get_bitfield y lo hi) (fun i -> let a = nth (get_bitfield x lo hi) i in let b = nth (get_bitfield y lo hi) i in nth_get_bitfield x lo hi i; nth_get_bitfield y lo hi i; if i < hi - lo then begin if i < mi - lo then begin nth_get_bitfield x lo mi i; nth_get_bitfield y lo mi i end else begin nth_get_bitfield x mi hi (i + lo - mi); nth_get_bitfield y mi hi (i + lo - mi) end end ) #pop-options let get_bitfield_partition_2 (#tot: pos) (mid: nat { mid <= tot }) (x y: U.uint_t tot) : Lemma (requires ( get_bitfield x 0 mid == get_bitfield y 0 mid /\ get_bitfield x mid tot == get_bitfield y mid tot )) (ensures ( x == y )) = get_bitfield_partition_2_gen 0 mid tot x y; get_bitfield_full x; get_bitfield_full y let rec get_bitfield_partition' (#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (l: list nat) : Lemma (requires (get_bitfield_partition_prop x y lo hi l)) (ensures (get_bitfield x lo hi == get_bitfield y lo hi)) (decreases l) = match l with | [] -> () | mi :: q -> get_bitfield_partition' x y mi hi q; get_bitfield_partition_2_gen lo mi hi x y let get_bitfield_partition = get_bitfield_partition' let rec nth_size (n1: nat) (n2: nat { n1 <= n2 }) (x: U.uint_t n1) (i: nat { i < n2 }) : Lemma (x < pow2 n2 /\ nth #n2 x i == (i < n1 && nth #n1 x i)) = M.pow2_le_compat n2 n1; if i < n1 then begin if i = 0 then () else nth_size (n1 - 1) (n2 - 1) (x / 2) (i - 1) end else nth_le_pow2_m #n2 x n1 i let get_bitfield_size (tot1 tot2: pos) (x: nat { x < pow2 tot1 /\ tot1 <= tot2 }) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot1 }) : Lemma (x < pow2 tot2 /\ (get_bitfield #tot1 x lo hi <: nat) == (get_bitfield #tot2 x lo hi <: nat)) = M.pow2_le_compat tot2 tot1; eq_nth #tot2 (get_bitfield #tot1 x lo hi) (get_bitfield #tot2 x lo hi) (fun i -> let y1 = nth #tot2 (get_bitfield #tot1 x lo hi) i in let y2 = nth #tot2 (get_bitfield #tot2 x lo hi) i in nth_get_bitfield #tot2 x lo hi i; assert (y2 == (i < hi - lo && nth #tot2 x (i + lo))); nth_size tot1 tot2 (get_bitfield #tot1 x lo hi) i; assert (y1 == (i < tot1 && nth #tot1 (get_bitfield #tot1 x lo hi) i)); if i < tot1 then begin nth_get_bitfield #tot1 x lo hi i; assert (y1 == (i < hi - lo && nth #tot1 x (i + lo))); if i < hi - lo then nth_size tot1 tot2 x (i + lo) end ) let set_bitfield_size (tot1 tot2: pos) (x: nat { x < pow2 tot1 /\ tot1 <= tot2 }) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot1 }) (v: ubitfield tot1 (hi - lo)) : Lemma (x < pow2 tot2 /\ v < pow2 tot2 /\ (set_bitfield #tot1 x lo hi v <: nat) == (set_bitfield #tot2 x lo hi v <: nat)) = M.pow2_le_compat tot2 tot1; eq_nth #tot2 (set_bitfield #tot1 x lo hi v) (set_bitfield #tot2 x lo hi v) (fun i -> let y1 = nth #tot2 (set_bitfield #tot1 x lo hi v) i in let y2 = nth #tot2 (set_bitfield #tot2 x lo hi v) i in nth_set_bitfield #tot2 x lo hi v i; nth_size tot1 tot2 (set_bitfield #tot1 x lo hi v) i; nth_size tot1 tot2 x i; if i < tot1 then begin nth_set_bitfield #tot1 x lo hi v i; if lo <= i && i < hi then nth_size tot1 tot2 v (i - lo) end ) let set_bitfield_bound (#tot: pos) (x: U.uint_t tot) (bound: nat { bound <= tot /\ x < pow2 bound }) (lo: nat) (hi: nat { lo <= hi /\ hi <= bound }) (v: ubitfield tot (hi - lo)) : Lemma (set_bitfield x lo hi v < pow2 bound) = if bound = 0 then set_bitfield_empty x lo v else begin M.pow2_le_compat tot bound; M.pow2_le_compat bound (hi - lo); set_bitfield_size bound tot x lo hi v end #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --fuel 0 --ifuel 0" let set_bitfield_set_bitfield_get_bitfield #tot x lo hi lo' hi' v' = set_bitfield_bound (get_bitfield x lo hi) (hi - lo) lo' hi' v' ; let x1 = set_bitfield x lo hi (set_bitfield (get_bitfield x lo hi) lo' hi' v') in let x2 = set_bitfield x (lo + lo') (lo + hi') v' in eq_nth x1 x2 (fun i -> nth_set_bitfield x lo hi (set_bitfield (get_bitfield x lo hi) lo' hi' v') i; nth_set_bitfield x (lo + lo') (lo + hi') v' i ; if lo <= i && i < hi then begin assert (nth x1 i == nth (set_bitfield (get_bitfield x lo hi) lo' hi' v') (i - lo)); nth_set_bitfield (get_bitfield x lo hi) lo' hi' v' (i - lo); if lo' <= i - lo && i - lo < hi' then begin () end else begin assert (nth x2 i == nth x i); assert (nth x1 i == nth (get_bitfield x lo hi) (i - lo)); nth_get_bitfield x lo hi (i - lo); assert (i - lo + lo == i) end end ) #pop-options let mod_1 (x: int) : Lemma (x % 1 == 0) = () let div_1 (x: int) : Lemma (x / 1 == x) = () let get_bitfield_eq (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Lemma (get_bitfield x lo hi == (x / pow2 lo) % pow2 (hi - lo)) = if hi - lo = 0 then begin assert (hi == lo); assert_norm (pow2 0 == 1); mod_1 (x / pow2 lo); get_bitfield_empty #tot x lo end else if hi - lo = tot then begin assert (hi == tot); assert (lo == 0); assert_norm (pow2 0 == 1); div_1 x; M.small_mod x (pow2 tot); get_bitfield_full #tot x end else begin assert (hi - lo < tot); U.shift_right_logand_lemma #tot x (bitfield_mask tot lo hi) lo; U.shift_right_value_lemma #tot (bitfield_mask tot lo hi) lo; M.multiple_division_lemma (pow2 (hi - lo) - 1) (pow2 lo); U.logand_mask #tot (U.shift_right x lo) (hi - lo); U.shift_right_value_lemma #tot x lo end let pow2_m_minus_one_eq (n: nat) (m: nat) : Lemma (requires (m <= n)) (ensures ( (pow2 n - 1) / pow2 m == pow2 (n - m) - 1 )) = M.pow2_le_compat n m; M.pow2_plus (n - m) m; M.division_definition (pow2 n - 1) (pow2 m) (pow2 (n - m) - 1) let get_bitfield_eq_2 (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Lemma (get_bitfield x lo hi == (x `U.shift_left` (tot - hi)) `U.shift_right` (tot - hi + lo)) = eq_nth (get_bitfield x lo hi) ((x `U.shift_left` (tot - hi)) `U.shift_right` (tot - hi + lo)) (fun i -> nth_get_bitfield x lo hi i; nth_shift_right (x `U.shift_left` (tot - hi)) (tot - hi + lo) i; let j = i + (tot - hi + lo) in if j < tot then nth_shift_left x (tot - hi) j ) #restart-solver let bitfield_mask_eq_2 (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Lemma ( bitfield_mask tot lo hi == U.shift_left #tot (U.lognot 0 `U.shift_right` (tot - (hi - lo))) lo ) = bitfield_mask_eq tot lo hi; pow2_m_minus_one_eq tot (tot - (hi - lo)); U.lemma_lognot_value_mod #tot 0; U.shift_right_value_lemma #tot (pow2 tot - 1) (tot - (hi - lo)) let set_bitfield_eq (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) : Lemma (set_bitfield x lo hi v == (x `U.logand` U.lognot ((U.lognot 0 `U.shift_right` (tot - (hi - lo))) `U.shift_left` lo)) `U.logor` (v `U.shift_left` lo)) = bitfield_mask_eq_2 tot lo hi module U32 = FStar.UInt32 module U64 = FStar.UInt64 module U16 = FStar.UInt16 module U8 = FStar.UInt8 (* Instantiate to UInt64 *) #push-options "--z3rlimit 32" inline_for_extraction let bitfield_mask64 (lo: nat) (hi: nat { lo <= hi /\ hi <= 64 }) : Tot (x: U64.t { U64.v x == bitfield_mask 64 lo hi }) = if lo = hi then 0uL else begin bitfield_mask_eq_2 64 lo hi; (U64.lognot 0uL `U64.shift_right` (64ul `U32.sub` (U32.uint_to_t (hi - lo)))) `U64.shift_left` U32.uint_to_t lo end inline_for_extraction let u64_shift_right (x: U64.t) (amount: U32.t { U32.v amount <= 64 }) : Tot (y: U64.t { U64.v y == U64.v x `U.shift_right` U32.v amount }) = if amount = 64ul then 0uL else x `U64.shift_right` amount inline_for_extraction let get_bitfield64 (x: U64.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 64}) : Tot (y: U64.t { U64.v y == get_bitfield (U64.v x) lo hi }) = (x `U64.logand` bitfield_mask64 lo hi) `u64_shift_right` (U32.uint_to_t lo) inline_for_extraction let not_bitfield_mask64 (lo: nat) (hi: nat { lo <= hi /\ hi <= 64 }) : Tot (x: U64.t { U64.v x == not_bitfield_mask 64 lo hi }) = U64.lognot (bitfield_mask64 lo hi) inline_for_extraction let u64_shift_left (x: U64.t) (amount: U32.t { U32.v amount <= 64 }) : Tot (y: U64.t { U64.v y == U64.v x `U.shift_left` U32.v amount }) = if amount = 64ul then 0uL else x `U64.shift_left` amount inline_for_extraction let set_bitfield64 (x: U64.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 64}) (v: U64.t { U64.v v < pow2 (hi - lo) }) : Tot (y: U64.t { U64.v y == set_bitfield (U64.v x) lo hi (U64.v v) }) = (x `U64.logand` not_bitfield_mask64 lo hi) `U64.logor` (v `u64_shift_left` U32.uint_to_t lo) inline_for_extraction let bitfield_eq64_lhs (x: U64.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 64}) : Tot U64.t = x `U64.logand` bitfield_mask64 lo hi #push-options "--z3rlimit 16" inline_for_extraction let bitfield_eq64_rhs (x: U64.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 64}) (v: U64.t { U64.v v < pow2 (hi - lo) }) : Tot (y: U64.t { bitfield_eq64_lhs x lo hi == y <==> (get_bitfield64 x lo hi <: U64.t) == v }) = [@inline_let] let _ = bitfield_eq_shift (U64.v x) lo hi (U64.v v) in v `u64_shift_left` U32.uint_to_t lo #pop-options inline_for_extraction let get_bitfield_gen64 (x: U64.t) (lo: U32.t) (hi: U32.t {U32.v lo < U32.v hi /\ U32.v hi <= 64}) : Tot (y: U64.t { U64.v y == get_bitfield (U64.v x) (U32.v lo) (U32.v hi) }) = get_bitfield_eq_2 #64 (U64.v x) (U32.v lo) (U32.v hi); (x `U64.shift_left` (64ul `U32.sub` hi)) `U64.shift_right` ((64ul `U32.sub` hi) `U32.add` lo) inline_for_extraction let set_bitfield_gen64 (x: U64.t) (lo: U32.t) (hi: U32.t {U32.v lo < U32.v hi /\ U32.v hi <= 64}) (v: U64.t { U64.v v < pow2 (U32.v hi - U32.v lo) }) : Tot (y: U64.t { U64.v y == set_bitfield (U64.v x) (U32.v lo) (U32.v hi) (U64.v v) }) = bitfield_mask_eq_2 64 (U32.v lo) (U32.v hi); (x `U64.logand` U64.lognot (((U64.lognot 0uL) `U64.shift_right` (64ul `U32.sub` (hi `U32.sub` lo))) `U64.shift_left` lo)) `U64.logor` (v `U64.shift_left` lo) (* Instantiate to UInt32 *) inline_for_extraction let bitfield_mask32 (lo: nat) (hi: nat { lo <= hi /\ hi <= 32 }) : Tot (x: U32.t { U32.v x == bitfield_mask 32 lo hi }) = if lo = hi then 0ul else begin bitfield_mask_eq_2 32 lo hi; (U32.lognot 0ul `U32.shift_right` (32ul `U32.sub` (U32.uint_to_t (hi - lo)))) `U32.shift_left` U32.uint_to_t lo end inline_for_extraction let u32_shift_right (x: U32.t) (amount: U32.t { U32.v amount <= 32 }) : Tot (y: U32.t { U32.v y == U32.v x `U.shift_right` U32.v amount }) = if amount = 32ul then 0ul else x `U32.shift_right` amount inline_for_extraction let get_bitfield32 (x: U32.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 32}) : Tot (y: U32.t { U32.v y == get_bitfield (U32.v x) lo hi }) = (x `U32.logand` bitfield_mask32 lo hi) `u32_shift_right` (U32.uint_to_t lo) inline_for_extraction let not_bitfield_mask32 (lo: nat) (hi: nat { lo <= hi /\ hi <= 32 }) : Tot (x: U32.t { U32.v x == not_bitfield_mask 32 lo hi }) = U32.lognot (bitfield_mask32 lo hi) inline_for_extraction let u32_shift_left (x: U32.t) (amount: U32.t { U32.v amount <= 32 }) : Tot (y: U32.t { U32.v y == U32.v x `U.shift_left` U32.v amount }) = if amount = 32ul then 0ul else x `U32.shift_left` amount inline_for_extraction let set_bitfield32 (x: U32.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 32}) (v: U32.t { U32.v v < pow2 (hi - lo) }) : Tot (y: U32.t { U32.v y == set_bitfield (U32.v x) lo hi (U32.v v) }) = (x `U32.logand` not_bitfield_mask32 lo hi) `U32.logor` (v `u32_shift_left` U32.uint_to_t lo) inline_for_extraction let bitfield_eq32_lhs (x: U32.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 32}) : Tot U32.t = x `U32.logand` bitfield_mask32 lo hi inline_for_extraction let bitfield_eq32_rhs (x: U32.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 32}) (v: U32.t { U32.v v < pow2 (hi - lo) }) : Tot (y: U32.t { bitfield_eq32_lhs x lo hi == y <==> (get_bitfield32 x lo hi <: U32.t) == v }) = [@inline_let] let _ = bitfield_eq_shift (U32.v x) lo hi (U32.v v) in v `u32_shift_left` U32.uint_to_t lo inline_for_extraction let get_bitfield_gen32 (x: U32.t) (lo: U32.t) (hi: U32.t {U32.v lo < U32.v hi /\ U32.v hi <= 32}) : Tot (y: U32.t { U32.v y == get_bitfield (U32.v x) (U32.v lo) (U32.v hi) }) = get_bitfield_eq_2 #32 (U32.v x) (U32.v lo) (U32.v hi); (x `U32.shift_left` (32ul `U32.sub` hi)) `U32.shift_right` ((32ul `U32.sub` hi) `U32.add` lo) #push-options "--z3rlimit 16" inline_for_extraction let set_bitfield_gen32 (x: U32.t) (lo: U32.t) (hi: U32.t {U32.v lo < U32.v hi /\ U32.v hi <= 32}) (v: U32.t { U32.v v < pow2 (U32.v hi - U32.v lo) }) : Tot (y: U32.t { U32.v y == set_bitfield (U32.v x) (U32.v lo) (U32.v hi) (U32.v v) }) = bitfield_mask_eq_2 32 (U32.v lo) (U32.v hi); (x `U32.logand` U32.lognot (((U32.lognot 0ul) `U32.shift_right` (32ul `U32.sub` (hi `U32.sub` lo))) `U32.shift_left` lo)) `U32.logor` (v `U32.shift_left` lo) #pop-options (* Instantiate to UInt16 *) inline_for_extraction let bitfield_mask16 (lo: nat) (hi: nat { lo <= hi /\ hi <= 16 }) : Tot (x: U16.t { U16.v x == bitfield_mask 16 lo hi }) = if lo = hi then 0us else begin bitfield_mask_eq_2 16 lo hi; (U16.lognot 0us `U16.shift_right` (16ul `U32.sub` (U32.uint_to_t (hi - lo)))) `U16.shift_left` U32.uint_to_t lo end inline_for_extraction let u16_shift_right (x: U16.t) (amount: U32.t { U32.v amount <= 16 }) : Tot (y: U16.t { U16.v y == U16.v x `U.shift_right` U32.v amount }) = if amount = 16ul then 0us else x `U16.shift_right` amount inline_for_extraction let get_bitfield16 (x: U16.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 16}) : Tot (y: U16.t { U16.v y == get_bitfield (U16.v x) lo hi }) = (x `U16.logand` bitfield_mask16 lo hi) `u16_shift_right` (U32.uint_to_t lo) inline_for_extraction let not_bitfield_mask16 (lo: nat) (hi: nat { lo <= hi /\ hi <= 16 }) : Tot (x: U16.t { U16.v x == not_bitfield_mask 16 lo hi }) = U16.lognot (bitfield_mask16 lo hi) inline_for_extraction let u16_shift_left (x: U16.t) (amount: U32.t { U32.v amount <= 16 }) : Tot (y: U16.t { U16.v y == U16.v x `U.shift_left` U32.v amount }) = if amount = 16ul then 0us else x `U16.shift_left` amount inline_for_extraction let set_bitfield16 (x: U16.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 16}) (v: U16.t { U16.v v < pow2 (hi - lo) }) : Tot (y: U16.t { U16.v y == set_bitfield (U16.v x) lo hi (U16.v v) }) = (x `U16.logand` not_bitfield_mask16 lo hi) `U16.logor` (v `u16_shift_left` U32.uint_to_t lo) inline_for_extraction let bitfield_eq16_lhs (x: U16.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 16}) : Tot U16.t = x `U16.logand` bitfield_mask16 lo hi inline_for_extraction let bitfield_eq16_rhs (x: U16.t) (lo: nat) (hi: nat {lo <= hi /\ hi <= 16}) (v: U16.t { U16.v v < pow2 (hi - lo) }) : Tot (y: U16.t { bitfield_eq16_lhs x lo hi == y <==> (get_bitfield16 x lo hi <: U16.t) == v }) = [@inline_let] let _ = bitfield_eq_shift (U16.v x) lo hi (U16.v v) in v `u16_shift_left` U32.uint_to_t lo inline_for_extraction let get_bitfield_gen16 (x: U16.t) (lo: U32.t) (hi: U32.t {U32.v lo < U32.v hi /\ U32.v hi <= 16}) : Tot (y: U16.t { U16.v y == get_bitfield (U16.v x) (U32.v lo) (U32.v hi) }) = get_bitfield_eq_2 #16 (U16.v x) (U32.v lo) (U32.v hi); (* avoid integer promotion again *) let bf : U16.t = x `U16.shift_left` (16ul `U32.sub` hi) in bf `U16.shift_right` ((16ul `U32.sub` hi) `U32.add` lo) inline_for_extraction let set_bitfield_gen16 (x: U16.t) (lo: U32.t) (hi: U32.t {U32.v lo < U32.v hi /\ U32.v hi <= 16}) (v: U16.t { U16.v v < pow2 (U32.v hi - U32.v lo) }) : Tot (y: U16.t { U16.v y == set_bitfield (U16.v x) (U32.v lo) (U32.v hi) (U16.v v) }) = bitfield_mask_eq_2 16 (U32.v lo) (U32.v hi); (x `U16.logand` U16.lognot (((U16.lognot 0us) `U16.shift_right` (16ul `U32.sub` (hi `U32.sub` lo))) `U16.shift_left` lo)) `U16.logor` (v `U16.shift_left` lo) inline_for_extraction let bitfield_mask8 (lo: nat) (hi: nat { lo <= hi /\ hi <= 8 }) : Tot (x: U8.t { U8.v x == bitfield_mask 8 lo hi }) = if lo = hi then 0uy else begin bitfield_mask_eq_2 8 lo hi; (U8.lognot 0uy `U8.shift_right` (8ul `U32.sub` (U32.uint_to_t (hi - lo)))) `U8.shift_left` U32.uint_to_t lo end inline_for_extraction let u8_shift_right (x: U8.t) (amount: U32.t { U32.v amount <= 8 }) : Tot (y: U8.t { U8.v y == U8.v x `U.shift_right` U32.v amount }) = let y = if amount = 8ul then 0uy else x `U8.shift_right` amount in y // inline_for_extraction // no, because of https://github.com/FStarLang/karamel/issues/102 let get_bitfield_gen8 (x: U8.t) (lo: U32.t) (hi: U32.t {U32.v lo < U32.v hi /\ U32.v hi <= 8}) : Tot (y: U8.t { U8.v y == get_bitfield (U8.v x) (U32.v lo) (U32.v hi) }) = get_bitfield_eq_2 #8 (U8.v x) (U32.v lo) (U32.v hi); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op1 = x `U8.shift_left` (8ul `U32.sub` hi) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` hi) `U32.add` lo) in op2 // inline_for_extraction // no, same let set_bitfield_gen8 (x: U8.t) (lo: U32.t) (hi: U32.t {U32.v lo < U32.v hi /\ U32.v hi <= 8}) (v: U8.t { U8.v v < pow2 (U32.v hi - U32.v lo) }) : Tot (y: U8.t { U8.v y == set_bitfield (U8.v x) (U32.v lo) (U32.v hi) (U8.v v) }) = bitfield_mask_eq_2 8 (U32.v lo) (U32.v hi); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op0 = (U8.lognot 0uy) in let op1 = op0 `U8.shift_right` (8ul `U32.sub` (hi `U32.sub` lo)) in let op2 = op1 `U8.shift_left` lo in let op3 = U8.lognot op2 in let op4 = x `U8.logand` op3 in let op5 = v `U8.shift_left` lo in let op6 = op4 `U8.logor` op5 in op6
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.BitFields.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": false, "full_module": "LowParse", "short_module": null }, { "abbrev": false, "full_module": "LowParse", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt8.t -> lo: Prims.nat -> hi: Prims.nat{lo <= hi /\ hi <= 8} -> y: FStar.UInt8.t{FStar.UInt8.v y == LowParse.BitFields.get_bitfield (FStar.UInt8.v x) lo hi}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "FStar.UInt8.__uint_to_t", "Prims.bool", "LowParse.BitFields.get_bitfield_gen8", "FStar.UInt32.uint_to_t", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt8.n", "FStar.UInt8.v", "LowParse.BitFields.get_bitfield" ]
[]
false
false
false
false
false
let get_bitfield8 (x: U8.t) (lo: nat) (hi: nat{lo <= hi /\ hi <= 8}) : Tot (y: U8.t{U8.v y == get_bitfield (U8.v x) lo hi}) =
if lo = hi then 0uy else get_bitfield_gen8 x (U32.uint_to_t lo) (U32.uint_to_t hi)
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.footprint
val footprint : st: EverCrypt.DRBG.state a -> h: FStar.Monotonic.HyperStack.mem -> Prims.GTot LowStar.Monotonic.Buffer.loc
let footprint (#a:supported_alg) (st:state a) (h:HS.mem) = B.loc_union (B.loc_addr_of_buffer st) (footprint_s (B.deref h st))
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 109, "start_col": 0, "start_line": 108 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0 inline_for_extraction noextract let state a = B.pointer (state_s a) inline_for_extraction noextract val freeable_s: #a:supported_alg -> st:state_s a -> Type0 inline_for_extraction noextract let freeable (#a:supported_alg) (st:state a) (h:HS.mem) = B.freeable st /\ freeable_s (B.deref h st) val footprint_s: #a:supported_alg -> state_s a -> GTot B.loc
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
st: EverCrypt.DRBG.state a -> h: FStar.Monotonic.HyperStack.mem -> Prims.GTot LowStar.Monotonic.Buffer.loc
Prims.GTot
[ "sometrivial" ]
[]
[ "EverCrypt.DRBG.supported_alg", "EverCrypt.DRBG.state", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "EverCrypt.DRBG.state_s", "LowStar.Buffer.trivial_preorder", "EverCrypt.DRBG.footprint_s", "LowStar.Monotonic.Buffer.deref", "LowStar.Monotonic.Buffer.loc" ]
[]
false
false
false
false
false
let footprint (#a: supported_alg) (st: state a) (h: HS.mem) =
B.loc_union (B.loc_addr_of_buffer st) (footprint_s (B.deref h st))
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.invariant
val invariant : st: EverCrypt.DRBG.state a -> h: FStar.Monotonic.HyperStack.mem -> Prims.logical
let invariant (#a:supported_alg) (st:state a) (h:HS.mem) = B.live h st /\ B.loc_disjoint (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) /\ invariant_s (B.deref h st) h
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 118, "start_col": 0, "start_line": 115 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0 inline_for_extraction noextract let state a = B.pointer (state_s a) inline_for_extraction noextract val freeable_s: #a:supported_alg -> st:state_s a -> Type0 inline_for_extraction noextract let freeable (#a:supported_alg) (st:state a) (h:HS.mem) = B.freeable st /\ freeable_s (B.deref h st) val footprint_s: #a:supported_alg -> state_s a -> GTot B.loc let footprint (#a:supported_alg) (st:state a) (h:HS.mem) = B.loc_union (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) inline_for_extraction noextract val invariant_s: #a:supported_alg -> state_s a -> HS.mem -> Type0
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
st: EverCrypt.DRBG.state a -> h: FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "EverCrypt.DRBG.state", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "EverCrypt.DRBG.state_s", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "EverCrypt.DRBG.footprint_s", "LowStar.Monotonic.Buffer.deref", "EverCrypt.DRBG.invariant_s", "Prims.logical" ]
[]
false
false
false
false
true
let invariant (#a: supported_alg) (st: state a) (h: HS.mem) =
B.live h st /\ B.loc_disjoint (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) /\ invariant_s (B.deref h st) h
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.disjoint_st
val disjoint_st : st: EverCrypt.DRBG.state a -> b: LowStar.Buffer.buffer t -> h: FStar.Monotonic.HyperStack.mem -> Type0
let disjoint_st (#t:Type) (#a:supported_alg) (st:state a) (b:B.buffer t) (h:HS.mem) = B.loc_disjoint (footprint st h) (B.loc_buffer b)
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 124, "start_col": 0, "start_line": 121 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0 inline_for_extraction noextract let state a = B.pointer (state_s a) inline_for_extraction noextract val freeable_s: #a:supported_alg -> st:state_s a -> Type0 inline_for_extraction noextract let freeable (#a:supported_alg) (st:state a) (h:HS.mem) = B.freeable st /\ freeable_s (B.deref h st) val footprint_s: #a:supported_alg -> state_s a -> GTot B.loc let footprint (#a:supported_alg) (st:state a) (h:HS.mem) = B.loc_union (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) inline_for_extraction noextract val invariant_s: #a:supported_alg -> state_s a -> HS.mem -> Type0 inline_for_extraction noextract let invariant (#a:supported_alg) (st:state a) (h:HS.mem) = B.live h st /\ B.loc_disjoint (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) /\ invariant_s (B.deref h st) h
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
st: EverCrypt.DRBG.state a -> b: LowStar.Buffer.buffer t -> h: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "EverCrypt.DRBG.state", "LowStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.loc_disjoint", "EverCrypt.DRBG.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.trivial_preorder" ]
[]
false
false
false
false
true
let disjoint_st (#t: Type) (#a: supported_alg) (st: state a) (b: B.buffer t) (h: HS.mem) =
B.loc_disjoint (footprint st h) (B.loc_buffer b)
false
Hacl.Impl.Lib.fst
Hacl.Impl.Lib.fill_elems
val fill_elems : fill_elems_st
val fill_elems : fill_elems_st
let fill_elems #t #a h0 n output refl footprint spec impl = [@inline_let] let refl' h (i:nat{i <= v n}) : GTot (S.generate_elem_a t a (v n) i) = refl h i, as_seq h (gsub output 0ul (size i)) in [@inline_let] let footprint' i = footprint i |+| loc (gsub output 0ul (size i)) in [@inline_let] let spec' h0 = S.generate_elem_f (v n) (spec h0) in let h0 = ST.get () in loop h0 n (S.generate_elem_a t a (v n)) refl' footprint' spec' (fun i -> Loops.unfold_repeat_gen (v n) (S.generate_elem_a t a (v n)) (spec' h0) (refl' h0 0) (v i); impl i; let h = ST.get() in FStar.Seq.lemma_split (as_seq h (gsub output 0ul (i +! 1ul))) (v i) ); let h1 = ST.get () in assert (refl' h1 (v n) == Loops.repeat_gen (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl' h0 0))
{ "file_name": "code/bignum/Hacl.Impl.Lib.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 106, "end_line": 68, "start_col": 0, "start_line": 49 }
module Hacl.Impl.Lib open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators module S = Hacl.Spec.Lib #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let fill_elems_st = #t:Type0 -> #a:Type0 -> h0:mem -> n:size_t -> output:lbuffer t n -> refl:(mem -> i:size_nat{i <= v n} -> GTot a) -> footprint:(i:size_nat{i <= v n} -> GTot (l:B.loc{B.loc_disjoint l (loc output) /\ B.address_liveness_insensitive_locs `B.loc_includes` l})) -> spec:(mem -> GTot (i:size_nat{i < v n} -> a -> a & t)) -> impl:(i:size_t{v i < v n} -> Stack unit (requires fun h -> modifies (footprint (v i) |+| loc (gsub output 0ul i)) h0 h) (ensures fun h1 _ h2 -> (let block1 = gsub output i 1ul in let c, e = spec h0 (v i) (refl h1 (v i)) in refl h2 (v i + 1) == c /\ LSeq.index (as_seq h2 block1) 0 == e /\ footprint (v i + 1) `B.loc_includes` footprint (v i) /\ modifies (footprint (v i + 1) |+| (loc block1)) h1 h2))) -> Stack unit (requires fun h -> h0 == h /\ live h output) (ensures fun _ _ h1 -> modifies (footprint (v n) |+| loc output) h0 h1 /\ (let s, o = S.generate_elems (v n) (v n) (spec h0) (refl h0 0) in refl h1 (v n) == s /\ as_seq #_ #t h1 output == o)) inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Lib.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Lib.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Lib", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": 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
Hacl.Impl.Lib.fill_elems_st
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "LowStar.Monotonic.Buffer.loc", "Prims.l_and", "LowStar.Monotonic.Buffer.loc_disjoint", "Lib.Buffer.loc", "Lib.Buffer.MUT", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "Prims.op_LessThan", "FStar.Pervasives.Native.tuple2", "Prims.unit", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.gsub", "FStar.UInt32.__uint_to_t", "Prims.eq2", "Prims.op_Addition", "Lib.Sequence.index", "Lib.Buffer.as_seq", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Prims._assert", "Hacl.Spec.Lib.generate_elem_a", "Lib.LoopCombinators.repeat_gen", "Hacl.Spec.Lib.generate_elem_f", "FStar.HyperStack.ST.get", "Lib.Buffer.loop", "FStar.Seq.Properties.lemma_split", "Lib.IntTypes.op_Plus_Bang", "Lib.LoopCombinators.unfold_repeat_gen", "Prims.nat", "Prims.op_Subtraction", "Prims.pow2", "Lib.IntTypes.size", "FStar.Pervasives.Native.Mktuple2", "Lib.Sequence.seq", "Lib.Sequence.length" ]
[]
false
false
false
true
false
let fill_elems #t #a h0 n output refl footprint spec impl =
[@@ inline_let ]let refl' h (i: nat{i <= v n}) : GTot (S.generate_elem_a t a (v n) i) = refl h i, as_seq h (gsub output 0ul (size i)) in [@@ inline_let ]let footprint' i = footprint i |+| loc (gsub output 0ul (size i)) in [@@ inline_let ]let spec' h0 = S.generate_elem_f (v n) (spec h0) in let h0 = ST.get () in loop h0 n (S.generate_elem_a t a (v n)) refl' footprint' spec' (fun i -> Loops.unfold_repeat_gen (v n) (S.generate_elem_a t a (v n)) (spec' h0) (refl' h0 0) (v i); impl i; let h = ST.get () in FStar.Seq.lemma_split (as_seq h (gsub output 0ul (i +! 1ul))) (v i)); let h1 = ST.get () in assert (refl' h1 (v n) == Loops.repeat_gen (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl' h0 0))
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.preserves_freeable
val preserves_freeable : st: EverCrypt.DRBG.state a -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Prims.logical
let preserves_freeable #a (st:state a) (h0 h1:HS.mem) = freeable st h0 ==> freeable st h1
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 163, "start_col": 0, "start_line": 162 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0 inline_for_extraction noextract let state a = B.pointer (state_s a) inline_for_extraction noextract val freeable_s: #a:supported_alg -> st:state_s a -> Type0 inline_for_extraction noextract let freeable (#a:supported_alg) (st:state a) (h:HS.mem) = B.freeable st /\ freeable_s (B.deref h st) val footprint_s: #a:supported_alg -> state_s a -> GTot B.loc let footprint (#a:supported_alg) (st:state a) (h:HS.mem) = B.loc_union (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) inline_for_extraction noextract val invariant_s: #a:supported_alg -> state_s a -> HS.mem -> Type0 inline_for_extraction noextract let invariant (#a:supported_alg) (st:state a) (h:HS.mem) = B.live h st /\ B.loc_disjoint (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) /\ invariant_s (B.deref h st) h inline_for_extraction noextract let disjoint_st (#t:Type) (#a:supported_alg) (st:state a) (b:B.buffer t) (h:HS.mem) = B.loc_disjoint (footprint st h) (B.loc_buffer b) val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a) /// TR: the following pattern is necessary because, if we generically /// add such a pattern directly on `loc_includes_union_l`, then /// verification will blowup whenever both sides of `loc_includes` are /// `loc_union`s. We would like to break all unions on the /// right-hand-side of `loc_includes` first, using /// `loc_includes_union_r`. Here the pattern is on `footprint_s`, /// because we already expose the fact that `footprint` is a /// `loc_union`. (In other words, the pattern should be on every /// smallest location that is not exposed to be a `loc_union`.) /// val loc_includes_union_l_footprint_s: #a:supported_alg -> l1:B.loc -> l2:B.loc -> st:state_s a -> Lemma (requires B.loc_includes l1 (footprint_s st) \/ B.loc_includes l2 (footprint_s st)) (ensures B.loc_includes (B.loc_union l1 l2) (footprint_s st)) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s st))] /// Needed to prove that the footprint is disjoint from any fresh location val invariant_loc_in_footprint: #a:supported_alg -> st:state a -> h:HS.mem -> Lemma (requires invariant st h) (ensures B.loc_in (footprint st h) h) [SMTPat (invariant st h)] val frame_invariant: #a:supported_alg -> l:B.loc -> st:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires invariant st h0 /\ B.loc_disjoint l (footprint st h0) /\ B.modifies l h0 h1) (ensures invariant st h1 /\ repr st h0 == repr st h1)
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
st: EverCrypt.DRBG.state a -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "EverCrypt.DRBG.state", "FStar.Monotonic.HyperStack.mem", "Prims.l_imp", "EverCrypt.DRBG.freeable", "Prims.logical" ]
[]
false
false
false
false
true
let preserves_freeable #a (st: state a) (h0: HS.mem) (h1: HS.mem) =
freeable st h0 ==> freeable st h1
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_rnds2_spec
val sha256_rnds2_spec (src1 src2 wk:quad32) : quad32
val sha256_rnds2_spec (src1 src2 wk:quad32) : quad32
let sha256_rnds2_spec = opaque_make sha256_rnds2_spec_def
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 76, "end_line": 51, "start_col": 19, "start_line": 51 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2 let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h') let sha256_rnds2_spec_def (src1 src2 wk:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1,b1,c1,d1,e1,f1,g1,h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2,b2,c2,d2,e2,f2,g2,h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src1: Vale.Def.Types_s.quad32 -> src2: Vale.Def.Types_s.quad32 -> wk: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.Def.Types_s.quad32", "Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_def" ]
[]
false
false
false
true
false
let sha256_rnds2_spec =
opaque_make sha256_rnds2_spec_def
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.uninstantiate_st
val uninstantiate_st : a: EverCrypt.DRBG.supported_alg -> Type0
let uninstantiate_st (a:supported_alg) = st:state a -> ST unit (requires fun h0 -> freeable st h0 /\ invariant st h0) (ensures fun h0 _ h1 -> B.modifies (footprint st h0) h0 h1)
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 303, "start_col": 0, "start_line": 299 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0 inline_for_extraction noextract let state a = B.pointer (state_s a) inline_for_extraction noextract val freeable_s: #a:supported_alg -> st:state_s a -> Type0 inline_for_extraction noextract let freeable (#a:supported_alg) (st:state a) (h:HS.mem) = B.freeable st /\ freeable_s (B.deref h st) val footprint_s: #a:supported_alg -> state_s a -> GTot B.loc let footprint (#a:supported_alg) (st:state a) (h:HS.mem) = B.loc_union (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) inline_for_extraction noextract val invariant_s: #a:supported_alg -> state_s a -> HS.mem -> Type0 inline_for_extraction noextract let invariant (#a:supported_alg) (st:state a) (h:HS.mem) = B.live h st /\ B.loc_disjoint (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) /\ invariant_s (B.deref h st) h inline_for_extraction noextract let disjoint_st (#t:Type) (#a:supported_alg) (st:state a) (b:B.buffer t) (h:HS.mem) = B.loc_disjoint (footprint st h) (B.loc_buffer b) val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a) /// TR: the following pattern is necessary because, if we generically /// add such a pattern directly on `loc_includes_union_l`, then /// verification will blowup whenever both sides of `loc_includes` are /// `loc_union`s. We would like to break all unions on the /// right-hand-side of `loc_includes` first, using /// `loc_includes_union_r`. Here the pattern is on `footprint_s`, /// because we already expose the fact that `footprint` is a /// `loc_union`. (In other words, the pattern should be on every /// smallest location that is not exposed to be a `loc_union`.) /// val loc_includes_union_l_footprint_s: #a:supported_alg -> l1:B.loc -> l2:B.loc -> st:state_s a -> Lemma (requires B.loc_includes l1 (footprint_s st) \/ B.loc_includes l2 (footprint_s st)) (ensures B.loc_includes (B.loc_union l1 l2) (footprint_s st)) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s st))] /// Needed to prove that the footprint is disjoint from any fresh location val invariant_loc_in_footprint: #a:supported_alg -> st:state a -> h:HS.mem -> Lemma (requires invariant st h) (ensures B.loc_in (footprint st h) h) [SMTPat (invariant st h)] val frame_invariant: #a:supported_alg -> l:B.loc -> st:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires invariant st h0 /\ B.loc_disjoint l (footprint st h0) /\ B.modifies l h0 h1) (ensures invariant st h1 /\ repr st h0 == repr st h1) inline_for_extraction noextract let preserves_freeable #a (st:state a) (h0 h1:HS.mem) = freeable st h0 ==> freeable st h1 inline_for_extraction val alloca: a:supported_alg -> StackInline (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st h1)) /\ invariant st h1) val create_in: a:supported_alg -> r:HS.rid -> ST (state a) (requires fun _ -> is_eternal_region r) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint st h1)) /\ invariant st h1 /\ freeable st h1) (** @type: true *) [@@ Comment "Create a DRBG state. @param a Hash algorithm to use. The possible instantiations are ... * `Spec_Hash_Definitions_SHA2_256`, * `Spec_Hash_Definitions_SHA2_384`, * `Spec_Hash_Definitions_SHA2_512`, and * `Spec_Hash_Definitions_SHA1`. @return DRBG state. Needs to be freed via `EverCrypt_DRBG_uninstantiate`."] val create: a:supported_alg -> ST (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ invariant st h1 /\ freeable st h1) inline_for_extraction noextract let instantiate_st (a:supported_alg) = st:state a -> personalization_string:B.buffer uint8 -> personalization_string_len:size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 personalization_string /\ disjoint_st st personalization_string h0 /\ B.length personalization_string = v personalization_string_len) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v personalization_string_len <= S.max_personalization_string_length /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ footprint st h0 == footprint st h1 /\ B.modifies (footprint st h0) h0 h1 /\ (exists entropy_input nonce. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ S.min_length a / 2 <= Seq.length nonce /\ Seq.length nonce <= S.max_length /\ repr st h1 == S.instantiate entropy_input nonce (B.as_seq h0 personalization_string))) inline_for_extraction noextract let reseed_st (a:supported_alg) = st:state a -> additional_input:B.buffer uint8 -> additional_input_len:size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 additional_input /\ disjoint_st st additional_input h0 /\ B.length additional_input = v additional_input_len) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v additional_input_len <= S.max_additional_input_length /\ footprint st h0 == footprint st h1 /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ B.modifies (footprint st h0) h0 h1 /\ (exists entropy_input. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ repr st h1 == S.reseed (repr st h0) entropy_input (B.as_seq h0 additional_input))) inline_for_extraction noextract let generate_st (a:supported_alg) = output:B.buffer uint8 -> st:state a -> n:size_t -> additional_input:B.buffer uint8 -> additional_input_len:size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 output /\ B.live h0 additional_input /\ disjoint_st st output h0 /\ disjoint_st st additional_input h0 /\ B.disjoint output additional_input /\ B.length additional_input = v additional_input_len /\ v n = B.length output) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v n <= S.max_output_length /\ v additional_input_len <= S.max_additional_input_length /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ footprint st h0 == footprint st h1 /\ B.modifies (B.loc_union (B.loc_buffer output) (footprint st h0)) h0 h1 /\ (exists entropy_input. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ (let st1 = S.reseed (repr st h0) entropy_input (B.as_seq h0 additional_input) in match S.generate st1 (v n) (B.as_seq h0 additional_input) with | None -> False // Always reseeds, so generation cannot fail | Some (out, st_) -> repr st h1 == st_ /\ B.as_seq h1 output == out)))
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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: EverCrypt.DRBG.supported_alg -> Type0
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "EverCrypt.DRBG.state", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverCrypt.DRBG.freeable", "EverCrypt.DRBG.invariant", "LowStar.Monotonic.Buffer.modifies", "EverCrypt.DRBG.footprint" ]
[]
false
false
false
true
true
let uninstantiate_st (a: supported_alg) =
st: state a -> ST unit (requires fun h0 -> freeable st h0 /\ invariant st h0) (ensures fun h0 _ h1 -> B.modifies (footprint st h0) h0 h1)
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_reveal
val sha256_rnds2_spec_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.X64.CryptoInstructions_s.sha256_rnds2_spec == Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_def)
let sha256_rnds2_spec_reveal = opaque_revealer (`%sha256_rnds2_spec) sha256_rnds2_spec sha256_rnds2_spec_def
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 120, "end_line": 52, "start_col": 12, "start_line": 52 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2 let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h') let sha256_rnds2_spec_def (src1 src2 wk:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1,b1,c1,d1,e1,f1,g1,h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2,b2,c2,d2,e2,f2,g2,h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in dst
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.X64.CryptoInstructions_s.sha256_rnds2_spec == Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_def)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.Def.Types_s.quad32", "Vale.X64.CryptoInstructions_s.sha256_rnds2_spec", "Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_def" ]
[]
true
false
true
false
false
let sha256_rnds2_spec_reveal =
opaque_revealer (`%sha256_rnds2_spec) sha256_rnds2_spec sha256_rnds2_spec_def
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_msg1_spec
val sha256_msg1_spec (src1 src2:quad32) : quad32
val sha256_msg1_spec (src1 src2:quad32) : quad32
let sha256_msg1_spec = opaque_make sha256_msg1_spec_def
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 74, "end_line": 65, "start_col": 19, "start_line": 65 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2 let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h') let sha256_rnds2_spec_def (src1 src2 wk:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1,b1,c1,d1,e1,f1,g1,h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2,b2,c2,d2,e2,f2,g2,h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in dst [@"opaque_to_smt"] let sha256_rnds2_spec = opaque_make sha256_rnds2_spec_def irreducible let sha256_rnds2_spec_reveal = opaque_revealer (`%sha256_rnds2_spec) sha256_rnds2_spec sha256_rnds2_spec_def let sha256_msg1_spec_def (src1 src2:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let w4 = uint_to_t src2.lo0 in let w3 = uint_to_t src1.hi3 in let w2 = uint_to_t src1.hi2 in let w1 = uint_to_t src1.lo1 in let w0 = uint_to_t src1.lo0 in Mkfour (v (add_mod w0 (_sigma0 SHA2_256 w1))) (v (add_mod w1 (_sigma0 SHA2_256 w2))) (v (add_mod w2 (_sigma0 SHA2_256 w3)))
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src1: Vale.Def.Types_s.quad32 -> src2: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.Def.Types_s.quad32", "Vale.X64.CryptoInstructions_s.sha256_msg1_spec_def" ]
[]
false
false
false
true
false
let sha256_msg1_spec =
opaque_make sha256_msg1_spec_def
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_msg1_spec_reveal
val sha256_msg1_spec_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.X64.CryptoInstructions_s.sha256_msg1_spec == Vale.X64.CryptoInstructions_s.sha256_msg1_spec_def)
let sha256_msg1_spec_reveal = opaque_revealer (`%sha256_msg1_spec) sha256_msg1_spec sha256_msg1_spec_def
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 116, "end_line": 66, "start_col": 12, "start_line": 66 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2 let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h') let sha256_rnds2_spec_def (src1 src2 wk:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1,b1,c1,d1,e1,f1,g1,h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2,b2,c2,d2,e2,f2,g2,h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in dst [@"opaque_to_smt"] let sha256_rnds2_spec = opaque_make sha256_rnds2_spec_def irreducible let sha256_rnds2_spec_reveal = opaque_revealer (`%sha256_rnds2_spec) sha256_rnds2_spec sha256_rnds2_spec_def let sha256_msg1_spec_def (src1 src2:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let w4 = uint_to_t src2.lo0 in let w3 = uint_to_t src1.hi3 in let w2 = uint_to_t src1.hi2 in let w1 = uint_to_t src1.lo1 in let w0 = uint_to_t src1.lo0 in Mkfour (v (add_mod w0 (_sigma0 SHA2_256 w1))) (v (add_mod w1 (_sigma0 SHA2_256 w2))) (v (add_mod w2 (_sigma0 SHA2_256 w3))) (v (add_mod w3 (_sigma0 SHA2_256 w4)))
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.X64.CryptoInstructions_s.sha256_msg1_spec == Vale.X64.CryptoInstructions_s.sha256_msg1_spec_def)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.Def.Types_s.quad32", "Vale.X64.CryptoInstructions_s.sha256_msg1_spec", "Vale.X64.CryptoInstructions_s.sha256_msg1_spec_def" ]
[]
true
false
true
false
false
let sha256_msg1_spec_reveal =
opaque_revealer (`%sha256_msg1_spec) sha256_msg1_spec sha256_msg1_spec_def
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_msg2_spec
val sha256_msg2_spec (src1 src2:quad32) : quad32
val sha256_msg2_spec (src1 src2:quad32) : quad32
let sha256_msg2_spec = opaque_make sha256_msg2_spec_def
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 74, "end_line": 77, "start_col": 19, "start_line": 77 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2 let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h') let sha256_rnds2_spec_def (src1 src2 wk:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1,b1,c1,d1,e1,f1,g1,h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2,b2,c2,d2,e2,f2,g2,h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in dst [@"opaque_to_smt"] let sha256_rnds2_spec = opaque_make sha256_rnds2_spec_def irreducible let sha256_rnds2_spec_reveal = opaque_revealer (`%sha256_rnds2_spec) sha256_rnds2_spec sha256_rnds2_spec_def let sha256_msg1_spec_def (src1 src2:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let w4 = uint_to_t src2.lo0 in let w3 = uint_to_t src1.hi3 in let w2 = uint_to_t src1.hi2 in let w1 = uint_to_t src1.lo1 in let w0 = uint_to_t src1.lo0 in Mkfour (v (add_mod w0 (_sigma0 SHA2_256 w1))) (v (add_mod w1 (_sigma0 SHA2_256 w2))) (v (add_mod w2 (_sigma0 SHA2_256 w3))) (v (add_mod w3 (_sigma0 SHA2_256 w4))) [@"opaque_to_smt"] let sha256_msg1_spec = opaque_make sha256_msg1_spec_def irreducible let sha256_msg1_spec_reveal = opaque_revealer (`%sha256_msg1_spec) sha256_msg1_spec sha256_msg1_spec_def let sha256_msg2_spec_def (src1 src2:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let w14 = uint_to_t src2.hi2 in let w15 = uint_to_t src2.hi3 in let w16 = add_mod (uint_to_t src1.lo0) (_sigma1 SHA2_256 w14) in let w17 = add_mod (uint_to_t src1.lo1) (_sigma1 SHA2_256 w15) in let w18 = add_mod (uint_to_t src1.hi2) (_sigma1 SHA2_256 w16) in let w19 = add_mod (uint_to_t src1.hi3) (_sigma1 SHA2_256 w17) in
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src1: Vale.Def.Types_s.quad32 -> src2: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.Def.Types_s.quad32", "Vale.X64.CryptoInstructions_s.sha256_msg2_spec_def" ]
[]
false
false
false
true
false
let sha256_msg2_spec =
opaque_make sha256_msg2_spec_def
false
LowParse.Spec.Option.fst
LowParse.Spec.Option.parse_option_kind
val parse_option_kind (k: parser_kind) : Tot parser_kind
val parse_option_kind (k: parser_kind) : Tot parser_kind
let parse_option_kind (k: parser_kind) : Tot parser_kind = { parser_kind_metadata = None; parser_kind_low = 0; parser_kind_high = k.parser_kind_high; parser_kind_subkind = None; }
{ "file_name": "src/lowparse/LowParse.Spec.Option.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 1, "end_line": 13, "start_col": 0, "start_line": 8 }
module LowParse.Spec.Option include LowParse.Spec.Base module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Option.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "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
k: LowParse.Spec.Base.parser_kind -> LowParse.Spec.Base.parser_kind
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.Mkparser_kind'", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "FStar.Pervasives.Native.None", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.parser_kind_metadata_some" ]
[]
false
false
false
true
false
let parse_option_kind (k: parser_kind) : Tot parser_kind =
{ parser_kind_metadata = None; parser_kind_low = 0; parser_kind_high = k.parser_kind_high; parser_kind_subkind = None }
false
LowParse.Spec.Option.fst
LowParse.Spec.Option.serialize_option_bare
val serialize_option_bare (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot (bare_serializer (option t))
val serialize_option_bare (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot (bare_serializer (option t))
let serialize_option_bare (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot (bare_serializer (option t)) = fun x -> match x with | None -> Seq.empty | Some y -> serialize s y
{ "file_name": "src/lowparse/LowParse.Spec.Option.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 27, "end_line": 38, "start_col": 0, "start_line": 35 }
module LowParse.Spec.Option include LowParse.Spec.Base module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32 let parse_option_kind (k: parser_kind) : Tot parser_kind = { parser_kind_metadata = None; parser_kind_low = 0; parser_kind_high = k.parser_kind_high; parser_kind_subkind = None; } let parse_option_bare (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (bare_parser (option t)) = fun (input: bytes) -> match parse p input with | Some (data, consumed) -> Some (Some data, consumed) | _ -> Some (None, (0 <: consumed_length input)) let parse_option_bare_injective (#k: parser_kind) (#t: Type) (p: parser k t) (b1 b2: bytes) : Lemma (requires (injective_precond (parse_option_bare p) b1 b2)) (ensures (injective_postcond (parse_option_bare p) b1 b2)) = parser_kind_prop_equiv k p; match parse p b1, parse p b2 with | Some _, Some _ -> assert (injective_precond p b1 b2) | _ -> () let parse_option (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (parser (parse_option_kind k) (option t)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (parse_option_bare_injective p x)); parser_kind_prop_equiv k p; parser_kind_prop_equiv (parse_option_kind k) (parse_option_bare p); parse_option_bare p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Option.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "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
s: LowParse.Spec.Base.serializer p -> LowParse.Spec.Base.bare_serializer (FStar.Pervasives.Native.option t)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "FStar.Pervasives.Native.option", "FStar.Seq.Base.empty", "LowParse.Bytes.byte", "LowParse.Spec.Base.serialize", "LowParse.Bytes.bytes", "LowParse.Spec.Base.bare_serializer" ]
[]
false
false
false
false
false
let serialize_option_bare (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot (bare_serializer (option t)) =
function | None -> Seq.empty | Some y -> serialize s y
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.max_length
val max_length:n: size_t{v n == S.max_length}
val max_length:n: size_t{v n == S.max_length}
let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length)
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 69, "start_col": 0, "start_line": 67 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length)
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
n: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v n == Spec.HMAC_DRBG.max_length}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Spec.HMAC_DRBG.max_length", "Lib.IntTypes.mk_int", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_LessThan", "Prims.pow2" ]
[]
false
false
false
false
false
let max_length:n: size_t{v n == S.max_length} =
assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length)
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_msg2_spec_reveal
val sha256_msg2_spec_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.X64.CryptoInstructions_s.sha256_msg2_spec == Vale.X64.CryptoInstructions_s.sha256_msg2_spec_def)
let sha256_msg2_spec_reveal = opaque_revealer (`%sha256_msg2_spec) sha256_msg2_spec sha256_msg2_spec_def
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 116, "end_line": 78, "start_col": 12, "start_line": 78 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2 let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h') let sha256_rnds2_spec_def (src1 src2 wk:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1,b1,c1,d1,e1,f1,g1,h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2,b2,c2,d2,e2,f2,g2,h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in dst [@"opaque_to_smt"] let sha256_rnds2_spec = opaque_make sha256_rnds2_spec_def irreducible let sha256_rnds2_spec_reveal = opaque_revealer (`%sha256_rnds2_spec) sha256_rnds2_spec sha256_rnds2_spec_def let sha256_msg1_spec_def (src1 src2:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let w4 = uint_to_t src2.lo0 in let w3 = uint_to_t src1.hi3 in let w2 = uint_to_t src1.hi2 in let w1 = uint_to_t src1.lo1 in let w0 = uint_to_t src1.lo0 in Mkfour (v (add_mod w0 (_sigma0 SHA2_256 w1))) (v (add_mod w1 (_sigma0 SHA2_256 w2))) (v (add_mod w2 (_sigma0 SHA2_256 w3))) (v (add_mod w3 (_sigma0 SHA2_256 w4))) [@"opaque_to_smt"] let sha256_msg1_spec = opaque_make sha256_msg1_spec_def irreducible let sha256_msg1_spec_reveal = opaque_revealer (`%sha256_msg1_spec) sha256_msg1_spec sha256_msg1_spec_def let sha256_msg2_spec_def (src1 src2:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let w14 = uint_to_t src2.hi2 in let w15 = uint_to_t src2.hi3 in let w16 = add_mod (uint_to_t src1.lo0) (_sigma1 SHA2_256 w14) in let w17 = add_mod (uint_to_t src1.lo1) (_sigma1 SHA2_256 w15) in let w18 = add_mod (uint_to_t src1.hi2) (_sigma1 SHA2_256 w16) in let w19 = add_mod (uint_to_t src1.hi3) (_sigma1 SHA2_256 w17) in Mkfour (v w16) (v w17) (v w18) (v w19)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.X64.CryptoInstructions_s.sha256_msg2_spec == Vale.X64.CryptoInstructions_s.sha256_msg2_spec_def)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.Def.Types_s.quad32", "Vale.X64.CryptoInstructions_s.sha256_msg2_spec", "Vale.X64.CryptoInstructions_s.sha256_msg2_spec_def" ]
[]
true
false
true
false
false
let sha256_msg2_spec_reveal =
opaque_revealer (`%sha256_msg2_spec) sha256_msg2_spec sha256_msg2_spec_def
false
LowParse.Spec.Option.fst
LowParse.Spec.Option.parse_option_bare
val parse_option_bare (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (bare_parser (option t))
val parse_option_bare (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (bare_parser (option t))
let parse_option_bare (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (bare_parser (option t)) = fun (input: bytes) -> match parse p input with | Some (data, consumed) -> Some (Some data, consumed) | _ -> Some (None, (0 <: consumed_length input))
{ "file_name": "src/lowparse/LowParse.Spec.Option.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 50, "end_line": 19, "start_col": 0, "start_line": 15 }
module LowParse.Spec.Option include LowParse.Spec.Base module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32 let parse_option_kind (k: parser_kind) : Tot parser_kind = { parser_kind_metadata = None; parser_kind_low = 0; parser_kind_high = k.parser_kind_high; parser_kind_subkind = None; }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Option.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "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
p: LowParse.Spec.Base.parser k t -> LowParse.Spec.Base.bare_parser (FStar.Pervasives.Native.option t)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse", "LowParse.Spec.Base.consumed_length", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.None", "LowParse.Spec.Base.bare_parser" ]
[]
false
false
false
false
false
let parse_option_bare (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (bare_parser (option t)) =
fun (input: bytes) -> match parse p input with | Some (data, consumed) -> Some (Some data, consumed) | _ -> Some (None, (0 <: consumed_length input))
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.reseed_interval
val reseed_interval:n: size_t{v n == S.reseed_interval}
val reseed_interval:n: size_t{v n == S.reseed_interval}
let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval)
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 59, "start_col": 0, "start_line": 57 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
n: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v n == Spec.HMAC_DRBG.reseed_interval}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Spec.HMAC_DRBG.reseed_interval", "Lib.IntTypes.mk_int", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_LessThan", "Prims.pow2" ]
[]
false
false
false
false
false
let reseed_interval:n: size_t{v n == S.reseed_interval} =
assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval)
false
LowParse.Spec.Option.fst
LowParse.Spec.Option.parse_option_bare_injective
val parse_option_bare_injective (#k: parser_kind) (#t: Type) (p: parser k t) (b1 b2: bytes) : Lemma (requires (injective_precond (parse_option_bare p) b1 b2)) (ensures (injective_postcond (parse_option_bare p) b1 b2))
val parse_option_bare_injective (#k: parser_kind) (#t: Type) (p: parser k t) (b1 b2: bytes) : Lemma (requires (injective_precond (parse_option_bare p) b1 b2)) (ensures (injective_postcond (parse_option_bare p) b1 b2))
let parse_option_bare_injective (#k: parser_kind) (#t: Type) (p: parser k t) (b1 b2: bytes) : Lemma (requires (injective_precond (parse_option_bare p) b1 b2)) (ensures (injective_postcond (parse_option_bare p) b1 b2)) = parser_kind_prop_equiv k p; match parse p b1, parse p b2 with | Some _, Some _ -> assert (injective_precond p b1 b2) | _ -> ()
{ "file_name": "src/lowparse/LowParse.Spec.Option.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 11, "end_line": 27, "start_col": 0, "start_line": 21 }
module LowParse.Spec.Option include LowParse.Spec.Base module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32 let parse_option_kind (k: parser_kind) : Tot parser_kind = { parser_kind_metadata = None; parser_kind_low = 0; parser_kind_high = k.parser_kind_high; parser_kind_subkind = None; } let parse_option_bare (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (bare_parser (option t)) = fun (input: bytes) -> match parse p input with | Some (data, consumed) -> Some (Some data, consumed) | _ -> Some (None, (0 <: consumed_length input))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Option.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "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
p: LowParse.Spec.Base.parser k t -> b1: LowParse.Bytes.bytes -> b2: LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (requires LowParse.Spec.Base.injective_precond (LowParse.Spec.Option.parse_option_bare p) b1 b2) (ensures LowParse.Spec.Base.injective_postcond (LowParse.Spec.Option.parse_option_bare p) b1 b2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Bytes.bytes", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "Prims._assert", "LowParse.Spec.Base.injective_precond", "Prims.unit", "LowParse.Spec.Base.parser_kind_prop_equiv", "LowParse.Spec.Option.parse_option_bare", "Prims.squash", "LowParse.Spec.Base.injective_postcond", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let parse_option_bare_injective (#k: parser_kind) (#t: Type) (p: parser k t) (b1 b2: bytes) : Lemma (requires (injective_precond (parse_option_bare p) b1 b2)) (ensures (injective_postcond (parse_option_bare p) b1 b2)) =
parser_kind_prop_equiv k p; match parse p b1, parse p b2 with | Some _, Some _ -> assert (injective_precond p b1 b2) | _ -> ()
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.max_output_length
val max_output_length:n: size_t{v n == S.max_output_length}
val max_output_length:n: size_t{v n == S.max_output_length}
let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length)
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 64, "start_col": 0, "start_line": 62 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval)
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
n: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v n == Spec.HMAC_DRBG.max_output_length}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Spec.HMAC_DRBG.max_output_length", "Lib.IntTypes.mk_int", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_LessThan", "Prims.pow2" ]
[]
false
false
false
false
false
let max_output_length:n: size_t{v n == S.max_output_length} =
assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length)
false
LowParse.Spec.Option.fst
LowParse.Spec.Option.parse_option
val parse_option (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (parser (parse_option_kind k) (option t))
val parse_option (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (parser (parse_option_kind k) (option t))
let parse_option (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (parser (parse_option_kind k) (option t)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (parse_option_bare_injective p x)); parser_kind_prop_equiv k p; parser_kind_prop_equiv (parse_option_kind k) (parse_option_bare p); parse_option_bare p
{ "file_name": "src/lowparse/LowParse.Spec.Option.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 21, "end_line": 33, "start_col": 0, "start_line": 29 }
module LowParse.Spec.Option include LowParse.Spec.Base module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32 let parse_option_kind (k: parser_kind) : Tot parser_kind = { parser_kind_metadata = None; parser_kind_low = 0; parser_kind_high = k.parser_kind_high; parser_kind_subkind = None; } let parse_option_bare (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (bare_parser (option t)) = fun (input: bytes) -> match parse p input with | Some (data, consumed) -> Some (Some data, consumed) | _ -> Some (None, (0 <: consumed_length input)) let parse_option_bare_injective (#k: parser_kind) (#t: Type) (p: parser k t) (b1 b2: bytes) : Lemma (requires (injective_precond (parse_option_bare p) b1 b2)) (ensures (injective_postcond (parse_option_bare p) b1 b2)) = parser_kind_prop_equiv k p; match parse p b1, parse p b2 with | Some _, Some _ -> assert (injective_precond p b1 b2) | _ -> ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Option.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "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
p: LowParse.Spec.Base.parser k t -> LowParse.Spec.Base.parser (LowParse.Spec.Option.parse_option_kind k) (FStar.Pervasives.Native.option t)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Option.parse_option_bare", "Prims.unit", "LowParse.Spec.Base.parser_kind_prop_equiv", "FStar.Pervasives.Native.option", "LowParse.Spec.Option.parse_option_kind", "FStar.Classical.forall_intro_2", "LowParse.Bytes.bytes", "Prims.l_imp", "LowParse.Spec.Base.injective_precond", "LowParse.Spec.Base.injective_postcond", "FStar.Classical.move_requires", "LowParse.Spec.Option.parse_option_bare_injective", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
false
false
false
let parse_option (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (parser (parse_option_kind k) (option t)) =
Classical.forall_intro_2 (fun x -> Classical.move_requires (parse_option_bare_injective p x)); parser_kind_prop_equiv k p; parser_kind_prop_equiv (parse_option_kind k) (parse_option_bare p); parse_option_bare p
false
LowParse.Spec.Option.fst
LowParse.Spec.Option.serialize_option
val serialize_option (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (u: squash (k.parser_kind_low > 0)) : Tot (serializer (parse_option p))
val serialize_option (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (u: squash (k.parser_kind_low > 0)) : Tot (serializer (parse_option p))
let serialize_option (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (u: squash (k.parser_kind_low > 0)) : Tot (serializer (parse_option p)) = serialize_option_bare_correct s; serialize_option_bare s
{ "file_name": "src/lowparse/LowParse.Spec.Option.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 25, "end_line": 47, "start_col": 0, "start_line": 45 }
module LowParse.Spec.Option include LowParse.Spec.Base module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32 let parse_option_kind (k: parser_kind) : Tot parser_kind = { parser_kind_metadata = None; parser_kind_low = 0; parser_kind_high = k.parser_kind_high; parser_kind_subkind = None; } let parse_option_bare (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (bare_parser (option t)) = fun (input: bytes) -> match parse p input with | Some (data, consumed) -> Some (Some data, consumed) | _ -> Some (None, (0 <: consumed_length input)) let parse_option_bare_injective (#k: parser_kind) (#t: Type) (p: parser k t) (b1 b2: bytes) : Lemma (requires (injective_precond (parse_option_bare p) b1 b2)) (ensures (injective_postcond (parse_option_bare p) b1 b2)) = parser_kind_prop_equiv k p; match parse p b1, parse p b2 with | Some _, Some _ -> assert (injective_precond p b1 b2) | _ -> () let parse_option (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (parser (parse_option_kind k) (option t)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (parse_option_bare_injective p x)); parser_kind_prop_equiv k p; parser_kind_prop_equiv (parse_option_kind k) (parse_option_bare p); parse_option_bare p let serialize_option_bare (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot (bare_serializer (option t)) = fun x -> match x with | None -> Seq.empty | Some y -> serialize s y let serialize_option_bare_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Lemma (requires (k.parser_kind_low > 0)) (ensures (serializer_correct (parse_option p) (serialize_option_bare s))) = parser_kind_prop_equiv k p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Option.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "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
s: LowParse.Spec.Base.serializer p -> u63: Prims.squash (Mkparser_kind'?.parser_kind_low k > 0) -> LowParse.Spec.Base.serializer (LowParse.Spec.Option.parse_option p)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.squash", "Prims.b2t", "Prims.op_GreaterThan", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "LowParse.Spec.Option.serialize_option_bare", "Prims.unit", "LowParse.Spec.Option.serialize_option_bare_correct", "LowParse.Spec.Option.parse_option_kind", "FStar.Pervasives.Native.option", "LowParse.Spec.Option.parse_option" ]
[]
false
false
false
false
false
let serialize_option (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (u: squash (k.parser_kind_low > 0)) : Tot (serializer (parse_option p)) =
serialize_option_bare_correct s; serialize_option_bare s
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.max_personalization_string_length
val max_personalization_string_length:n: size_t{v n == S.max_personalization_string_length}
val max_personalization_string_length:n: size_t{v n == S.max_personalization_string_length}
let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length)
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 61, "end_line": 74, "start_col": 0, "start_line": 72 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length)
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
n: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v n == Spec.HMAC_DRBG.max_personalization_string_length}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Spec.HMAC_DRBG.max_personalization_string_length", "Lib.IntTypes.mk_int", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_LessThan", "Prims.pow2" ]
[]
false
false
false
false
false
let max_personalization_string_length:n: size_t{v n == S.max_personalization_string_length} =
assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length)
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.min_length
val min_length (a: supported_alg) : n: size_t{v n == S.min_length a}
val min_length (a: supported_alg) : n: size_t{v n == S.min_length a}
let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256))
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 85, "end_line": 85, "start_col": 0, "start_line": 81 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length)
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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: EverCrypt.DRBG.supported_alg -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n == Spec.HMAC_DRBG.min_length a}
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_t", "Prims.eq2", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.HMAC_DRBG.min_length", "Lib.IntTypes.mk_int", "Spec.Hash.Definitions.SHA1", "Spec.Hash.Definitions.SHA2_256", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2" ]
[]
false
false
false
false
false
let min_length (a: supported_alg) : n: size_t{v n == S.min_length a} =
assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256))
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.u1
val u1:universe
val u1:universe
let u1 : universe = R.pack_universe (R.Uv_Succ u0)
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 50, "end_line": 34, "start_col": 0, "start_line": 34 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.universe
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.V2.Builtins.pack_universe", "FStar.Stubs.Reflection.V2.Data.Uv_Succ", "Pulse.Syntax.Pure.u0" ]
[]
false
false
false
true
false
let u1:universe =
R.pack_universe (R.Uv_Succ u0)
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_update
val sha256_rnds2_spec_update : a: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> b: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> c: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> d: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> e: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> f: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> g: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> h: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> wk: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> ((((((FStar.UInt32.t * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * FStar.UInt32.t) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256
let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h')
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 33, "start_col": 0, "start_line": 14 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> b: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> c: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> d: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> e: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> f: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> g: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> h: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> wk: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256 -> ((((((FStar.UInt32.t * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * FStar.UInt32.t) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256) * Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_256
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.word", "Spec.Hash.Definitions.SHA2_256", "FStar.Pervasives.Native.Mktuple8", "FStar.UInt32.t", "FStar.UInt32.add_mod", "Spec.SHA2._Ch", "Spec.SHA2._Sigma1", "Spec.SHA2._Maj", "Spec.SHA2._Sigma0", "FStar.Pervasives.Native.tuple8" ]
[]
false
false
false
true
false
let sha256_rnds2_spec_update (a b c d e f g h wk: word SHA2_256) =
let open FStar.UInt32 in let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h')
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.u0
val u0:universe
val u0:universe
let u0 : universe = R.pack_universe R.Uv_Zero
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 45, "end_line": 33, "start_col": 0, "start_line": 33 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.universe
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.V2.Builtins.pack_universe", "FStar.Stubs.Reflection.V2.Data.Uv_Zero" ]
[]
false
false
false
true
false
let u0:universe =
R.pack_universe R.Uv_Zero
false
LowParse.Spec.Option.fst
LowParse.Spec.Option.serialize_option_bare_correct
val serialize_option_bare_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Lemma (requires (k.parser_kind_low > 0)) (ensures (serializer_correct (parse_option p) (serialize_option_bare s)))
val serialize_option_bare_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Lemma (requires (k.parser_kind_low > 0)) (ensures (serializer_correct (parse_option p) (serialize_option_bare s)))
let serialize_option_bare_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Lemma (requires (k.parser_kind_low > 0)) (ensures (serializer_correct (parse_option p) (serialize_option_bare s))) = parser_kind_prop_equiv k p
{ "file_name": "src/lowparse/LowParse.Spec.Option.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 43, "start_col": 0, "start_line": 40 }
module LowParse.Spec.Option include LowParse.Spec.Base module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32 let parse_option_kind (k: parser_kind) : Tot parser_kind = { parser_kind_metadata = None; parser_kind_low = 0; parser_kind_high = k.parser_kind_high; parser_kind_subkind = None; } let parse_option_bare (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (bare_parser (option t)) = fun (input: bytes) -> match parse p input with | Some (data, consumed) -> Some (Some data, consumed) | _ -> Some (None, (0 <: consumed_length input)) let parse_option_bare_injective (#k: parser_kind) (#t: Type) (p: parser k t) (b1 b2: bytes) : Lemma (requires (injective_precond (parse_option_bare p) b1 b2)) (ensures (injective_postcond (parse_option_bare p) b1 b2)) = parser_kind_prop_equiv k p; match parse p b1, parse p b2 with | Some _, Some _ -> assert (injective_precond p b1 b2) | _ -> () let parse_option (#k: parser_kind) (#t: Type) (p: parser k t) : Tot (parser (parse_option_kind k) (option t)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (parse_option_bare_injective p x)); parser_kind_prop_equiv k p; parser_kind_prop_equiv (parse_option_kind k) (parse_option_bare p); parse_option_bare p let serialize_option_bare (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot (bare_serializer (option t)) = fun x -> match x with | None -> Seq.empty | Some y -> serialize s y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Option.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "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
s: LowParse.Spec.Base.serializer p -> FStar.Pervasives.Lemma (requires Mkparser_kind'?.parser_kind_low k > 0) (ensures LowParse.Spec.Base.serializer_correct (LowParse.Spec.Option.parse_option p) (LowParse.Spec.Option.serialize_option_bare s))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.Spec.Base.parser_kind_prop_equiv", "Prims.unit", "Prims.b2t", "Prims.op_GreaterThan", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "Prims.squash", "LowParse.Spec.Base.serializer_correct", "LowParse.Spec.Option.parse_option_kind", "FStar.Pervasives.Native.option", "LowParse.Spec.Option.parse_option", "LowParse.Spec.Option.serialize_option_bare", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let serialize_option_bare_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Lemma (requires (k.parser_kind_low > 0)) (ensures (serializer_correct (parse_option p) (serialize_option_bare s))) =
parser_kind_prop_equiv k p
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.u_max
val u_max (u0 u1: universe) : universe
val u_max (u0 u1: universe) : universe
let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1])
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 37, "end_line": 43, "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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe =
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
u0: Pulse.Syntax.Base.universe -> u1: Pulse.Syntax.Base.universe -> Pulse.Syntax.Base.universe
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.universe", "FStar.Stubs.Reflection.V2.Builtins.pack_universe", "FStar.Stubs.Reflection.V2.Data.Uv_Max", "Prims.Cons", "FStar.Stubs.Reflection.Types.universe", "Prims.Nil" ]
[]
false
false
false
true
false
let u_max (u0 u1: universe) : universe =
R.pack_universe (R.Uv_Max [u0; u1])
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.u_zero
val u_zero : Pulse.Syntax.Base.universe
let u_zero = u0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 15, "end_line": 37, "start_col": 0, "start_line": 37 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1)
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.universe
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Pure.u0" ]
[]
false
false
false
true
false
let u_zero =
u0
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.u_succ
val u_succ (u: universe) : universe
val u_succ (u: universe) : universe
let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u)
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 39, "start_col": 0, "start_line": 38 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1)
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
u11: Pulse.Syntax.Base.universe -> Pulse.Syntax.Base.universe
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.universe", "FStar.Stubs.Reflection.V2.Builtins.pack_universe", "FStar.Stubs.Reflection.V2.Data.Uv_Succ" ]
[]
false
false
false
true
false
let u_succ (u: universe) : universe =
R.pack_universe (R.Uv_Succ u)
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.u_var
val u_var (s: string) : universe
val u_var (s: string) : universe
let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0)))
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 69, "end_line": 41, "start_col": 0, "start_line": 40 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe =
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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: Prims.string -> Pulse.Syntax.Base.universe
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "FStar.Stubs.Reflection.V2.Builtins.pack_universe", "FStar.Stubs.Reflection.V2.Data.Uv_Name", "FStar.Stubs.Reflection.V2.Builtins.pack_ident", "FStar.Pervasives.Native.Mktuple2", "FStar.Range.range", "FStar.Range.range_0", "Pulse.Syntax.Base.universe" ]
[]
false
false
false
true
false
let u_var (s: string) : universe =
R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0)))
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.instantiate_st
val instantiate_st : a: EverCrypt.DRBG.supported_alg -> Type0
let instantiate_st (a:supported_alg) = st:state a -> personalization_string:B.buffer uint8 -> personalization_string_len:size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 personalization_string /\ disjoint_st st personalization_string h0 /\ B.length personalization_string = v personalization_string_len) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v personalization_string_len <= S.max_personalization_string_length /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ footprint st h0 == footprint st h1 /\ B.modifies (footprint st h0) h0 h1 /\ (exists entropy_input nonce. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ S.min_length a / 2 <= Seq.length nonce /\ Seq.length nonce <= S.max_length /\ repr st h1 == S.instantiate entropy_input nonce (B.as_seq h0 personalization_string)))
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 80, "end_line": 230, "start_col": 0, "start_line": 204 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0 inline_for_extraction noextract let state a = B.pointer (state_s a) inline_for_extraction noextract val freeable_s: #a:supported_alg -> st:state_s a -> Type0 inline_for_extraction noextract let freeable (#a:supported_alg) (st:state a) (h:HS.mem) = B.freeable st /\ freeable_s (B.deref h st) val footprint_s: #a:supported_alg -> state_s a -> GTot B.loc let footprint (#a:supported_alg) (st:state a) (h:HS.mem) = B.loc_union (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) inline_for_extraction noextract val invariant_s: #a:supported_alg -> state_s a -> HS.mem -> Type0 inline_for_extraction noextract let invariant (#a:supported_alg) (st:state a) (h:HS.mem) = B.live h st /\ B.loc_disjoint (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) /\ invariant_s (B.deref h st) h inline_for_extraction noextract let disjoint_st (#t:Type) (#a:supported_alg) (st:state a) (b:B.buffer t) (h:HS.mem) = B.loc_disjoint (footprint st h) (B.loc_buffer b) val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a) /// TR: the following pattern is necessary because, if we generically /// add such a pattern directly on `loc_includes_union_l`, then /// verification will blowup whenever both sides of `loc_includes` are /// `loc_union`s. We would like to break all unions on the /// right-hand-side of `loc_includes` first, using /// `loc_includes_union_r`. Here the pattern is on `footprint_s`, /// because we already expose the fact that `footprint` is a /// `loc_union`. (In other words, the pattern should be on every /// smallest location that is not exposed to be a `loc_union`.) /// val loc_includes_union_l_footprint_s: #a:supported_alg -> l1:B.loc -> l2:B.loc -> st:state_s a -> Lemma (requires B.loc_includes l1 (footprint_s st) \/ B.loc_includes l2 (footprint_s st)) (ensures B.loc_includes (B.loc_union l1 l2) (footprint_s st)) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s st))] /// Needed to prove that the footprint is disjoint from any fresh location val invariant_loc_in_footprint: #a:supported_alg -> st:state a -> h:HS.mem -> Lemma (requires invariant st h) (ensures B.loc_in (footprint st h) h) [SMTPat (invariant st h)] val frame_invariant: #a:supported_alg -> l:B.loc -> st:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires invariant st h0 /\ B.loc_disjoint l (footprint st h0) /\ B.modifies l h0 h1) (ensures invariant st h1 /\ repr st h0 == repr st h1) inline_for_extraction noextract let preserves_freeable #a (st:state a) (h0 h1:HS.mem) = freeable st h0 ==> freeable st h1 inline_for_extraction val alloca: a:supported_alg -> StackInline (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st h1)) /\ invariant st h1) val create_in: a:supported_alg -> r:HS.rid -> ST (state a) (requires fun _ -> is_eternal_region r) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint st h1)) /\ invariant st h1 /\ freeable st h1) (** @type: true *) [@@ Comment "Create a DRBG state. @param a Hash algorithm to use. The possible instantiations are ... * `Spec_Hash_Definitions_SHA2_256`, * `Spec_Hash_Definitions_SHA2_384`, * `Spec_Hash_Definitions_SHA2_512`, and * `Spec_Hash_Definitions_SHA1`. @return DRBG state. Needs to be freed via `EverCrypt_DRBG_uninstantiate`."] val create: a:supported_alg -> ST (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ invariant st h1 /\ freeable st h1)
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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: EverCrypt.DRBG.supported_alg -> Type0
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "EverCrypt.DRBG.state", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size_t", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverCrypt.DRBG.invariant", "LowStar.Monotonic.Buffer.live", "LowStar.Buffer.trivial_preorder", "EverCrypt.DRBG.disjoint_st", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "LowStar.Monotonic.Buffer.length", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Prims.op_Negation", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.op_LessThanOrEqual", "Spec.HMAC_DRBG.max_personalization_string_length", "EverCrypt.DRBG.preserves_freeable", "Prims.eq2", "LowStar.Monotonic.Buffer.loc", "EverCrypt.DRBG.footprint", "Prims.l_Exists", "FStar.Seq.Base.seq", "Spec.HMAC_DRBG.min_length", "FStar.Seq.Base.length", "Spec.HMAC_DRBG.max_length", "Prims.op_Division", "Spec.HMAC_DRBG.state", "EverCrypt.DRBG.repr", "Spec.HMAC_DRBG.instantiate", "LowStar.Monotonic.Buffer.as_seq", "Prims.unit", "Spec.HMAC_DRBG.hmac_input_bound" ]
[]
false
false
false
true
true
let instantiate_st (a: supported_alg) =
st: state a -> personalization_string: B.buffer uint8 -> personalization_string_len: size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 personalization_string /\ disjoint_st st personalization_string h0 /\ B.length personalization_string = v personalization_string_len) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v personalization_string_len <= S.max_personalization_string_length /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ footprint st h0 == footprint st h1 /\ B.modifies (footprint st h0) h0 h1 /\ (exists entropy_input nonce. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ S.min_length a / 2 <= Seq.length nonce /\ Seq.length nonce <= S.max_length /\ repr st h1 == S.instantiate entropy_input nonce (B.as_seq h0 personalization_string) ))
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.u2
val u2:universe
val u2:universe
let u2 : universe = R.pack_universe (R.Uv_Succ u1)
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 50, "end_line": 35, "start_col": 0, "start_line": 35 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.universe
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.V2.Builtins.pack_universe", "FStar.Stubs.Reflection.V2.Data.Uv_Succ", "Pulse.Syntax.Pure.u1" ]
[]
false
false
false
true
false
let u2:universe =
R.pack_universe (R.Uv_Succ u1)
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.u_unknown
val u_unknown:universe
val u_unknown:universe
let u_unknown : universe = R.pack_universe R.Uv_Unk
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 51, "end_line": 44, "start_col": 0, "start_line": 44 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe =
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.universe
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.V2.Builtins.pack_universe", "FStar.Stubs.Reflection.V2.Data.Uv_Unk" ]
[]
false
false
false
true
false
let u_unknown:universe =
R.pack_universe R.Uv_Unk
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_def
val sha256_rnds2_spec_def (src1 src2 wk: quad32) : quad32
val sha256_rnds2_spec_def (src1 src2 wk: quad32) : quad32
let sha256_rnds2_spec_def (src1 src2 wk:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1,b1,c1,d1,e1,f1,g1,h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2,b2,c2,d2,e2,f2,g2,h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in dst
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 50, "start_col": 0, "start_line": 35 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2 let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h')
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src1: Vale.Def.Types_s.quad32 -> src2: Vale.Def.Types_s.quad32 -> wk: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Types_s.quad32", "FStar.UInt32.t", "Spec.Hash.Definitions.word", "Spec.Hash.Definitions.SHA2_256", "Vale.Def.Words_s.four", "Vale.Def.Words_s.nat32", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "FStar.UInt32.v", "FStar.Pervasives.Native.tuple8", "Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_update", "FStar.UInt32.uint_to_t", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3" ]
[]
false
false
false
true
false
let sha256_rnds2_spec_def (src1 src2 wk: quad32) : quad32 =
let open FStar.UInt32 in let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1, b1, c1, d1, e1, f1, g1, h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2, b2, c2, d2, e2, f2, g2, h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in dst
false
LowParse.BitFields.fst
LowParse.BitFields.get_bitfield_set_bitfield_same
val get_bitfield_set_bitfield_same (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) : Lemma (get_bitfield (set_bitfield x lo hi v) lo hi == v)
val get_bitfield_set_bitfield_same (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) : Lemma (get_bitfield (set_bitfield x lo hi v) lo hi == v)
let get_bitfield_set_bitfield_same (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) : Lemma (get_bitfield (set_bitfield x lo hi v) lo hi == v) = eq_nth (get_bitfield (set_bitfield x lo hi v) lo hi) v (fun i -> nth_get_bitfield (set_bitfield x lo hi v) lo hi i; if i < hi - lo then begin nth_set_bitfield x lo hi v (i + lo) end else nth_le_pow2_m v (hi - lo) i )
{ "file_name": "src/lowparse/LowParse.BitFields.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 343, "start_col": 0, "start_line": 331 }
module LowParse.BitFields module U = FStar.UInt module M = LowParse.Math open FStar.Mul inline_for_extraction let bitfield_mask (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Tot (U.uint_t tot) = [@inline_let] let _ = M.pow2_le_compat tot hi; M.pow2_plus (hi - lo) lo in normalize_term ((pow2 (hi - lo) - 1) * pow2 lo) let bitfield_mask_eq (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Lemma ( 0 <= pow2 (hi - lo) - 1 /\ pow2 (hi - lo) - 1 < pow2 tot /\ bitfield_mask tot lo hi == U.shift_left #tot (pow2 (hi - lo) - 1) lo ) = M.pow2_le_compat tot (hi - lo); U.shift_left_value_lemma #tot (pow2 (hi - lo) - 1) lo; M.pow2_le_compat tot hi; M.pow2_plus (hi - lo) lo; M.lemma_mult_nat (pow2 (hi - lo) - 1) (pow2 lo); M.lemma_mult_lt' (pow2 lo) (pow2 (hi - lo) - 1) (pow2 (hi - lo)); M.swap_mul (pow2 (hi - lo)) (pow2 lo); M.swap_mul (pow2 (hi - lo) - 1) (pow2 lo); M.modulo_lemma ((pow2 (hi - lo) - 1) * pow2 lo) (pow2 tot) (* Cf. U.index_to_vec_ones; WHY WHY WHY is it private? *) val nth_pow2_minus_one' : #n:pos -> m:nat{m <= n} -> i:nat{i < n} -> Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (i < n - m ==> U.nth #n (pow2 m - 1) i == false) /\ (n - m <= i ==> U.nth #n (pow2 m - 1) i == true))) let rec nth_pow2_minus_one' #n m i = let a = pow2 m - 1 in M.pow2_le_compat n m; if m = 0 then U.one_to_vec_lemma #n i else if m = n then U.ones_to_vec_lemma #n i else if i = n - 1 then () else nth_pow2_minus_one' #(n - 1) (m - 1) i (* Rephrasing with a more natural nth *) let nth (#n: pos) (a: U.uint_t n) (i: nat {i < n}) : Tot bool = U.nth a (n - 1 - i) let eq_nth (#n: pos) (a: U.uint_t n) (b: U.uint_t n) (f: ( (i: nat { i < n }) -> Lemma (nth a i == nth b i) )) : Lemma (a == b) = let g (i: nat { i < n }) : Lemma (U.nth a i == U.nth b i) = f (n - 1 - i) in Classical.forall_intro g; U.nth_lemma a b let nth_pow2_minus_one (#n:pos) (m:nat{m <= n}) (i:nat{i < n}) : Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (nth #n (pow2 m - 1) i == (i < m)))) = nth_pow2_minus_one' #n m (n - 1 - i) let nth_shift_left (#n: pos) (a: U.uint_t n) (s: nat) (i: nat {i < n}) : Lemma (nth (U.shift_left a s) i == (s <= i && nth a (i - s))) = () let nth_shift_right (#n: pos) (a: U.uint_t n) (s: nat) (i: nat {i < n}) : Lemma (nth (U.shift_right a s) i == (i + s < n && nth a (i + s))) = () let nth_bitfield_mask (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (i: nat {i < tot}) : Lemma (nth (bitfield_mask tot lo hi) i == (lo <= i && i < hi)) = bitfield_mask_eq tot lo hi; nth_shift_left #tot (pow2 (hi - lo) - 1) lo i; if i < lo then () else begin nth_pow2_minus_one #tot (hi - lo) (i - lo) end let get_bitfield_raw (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Tot (U.uint_t tot) = (x `U.logand` bitfield_mask tot lo hi) `U.shift_right` lo let nth_logand (#n: pos) (a b: U.uint_t n) (i: nat {i < n}) : Lemma (nth (a `U.logand` b) i == (nth a i && nth b i)) = () let nth_logor (#n: pos) (a b: U.uint_t n) (i: nat {i < n}) : Lemma (nth (a `U.logor` b) i == (nth a i || nth b i)) = () let nth_lognot (#n: pos) (a: U.uint_t n) (i: nat {i < n}) : Lemma (nth (U.lognot a) i == not (nth a i)) = () let nth_get_bitfield_raw (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) (i: nat {i < tot}) : Lemma (nth (get_bitfield_raw x lo hi) i == (i < hi - lo && nth x (i + lo))) = nth_shift_right (x `U.logand` bitfield_mask tot lo hi) lo i; if i + lo < tot then begin nth_logand x (bitfield_mask tot lo hi) (i + lo); nth_bitfield_mask tot lo hi (i + lo) end else () let get_bitfield_raw_eq_logand_pow2_hi_lo_minus_one (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Lemma (let y = get_bitfield_raw x lo hi in pow2 (hi - lo) - 1 < pow2 tot /\ y == y `U.logand` (pow2 (hi - lo) - 1) ) = nth_pow2_minus_one #tot (hi - lo) 0; let y = get_bitfield_raw x lo hi in eq_nth y (y `U.logand` (pow2 (hi - lo) - 1)) (fun i -> nth_get_bitfield_raw x lo hi i; nth_pow2_minus_one #tot (hi - lo) i; nth_logand y (pow2 (hi - lo) - 1) i ) #push-options "--z3rlimit 16" let logand_mask (#n: pos) (a: U.uint_t n) (m: nat {m <= n}) : Lemma (pow2 m <= pow2 n /\ U.logand a (pow2 m - 1) == a % pow2 m) = M.pow2_le_compat n m; if m = 0 then begin U.logand_lemma_1 a end else if m = n then begin U.logand_lemma_2 a; M.modulo_lemma a (pow2 m) end else begin U.logand_mask a m end #pop-options let nth_le_pow2_m (#n: pos) (a: U.uint_t n) (m: nat {m <= n}) (i: nat {i < n}) : Lemma (requires (a < pow2 m /\ m <= i)) (ensures (nth a i == false)) = logand_mask a m; M.modulo_lemma a (pow2 m); nth_pow2_minus_one #n m i; nth_logand a (pow2 m - 1) i let get_bitfield_raw_bounded (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Lemma (get_bitfield_raw x lo hi < pow2 (hi - lo)) = get_bitfield_raw_eq_logand_pow2_hi_lo_minus_one x lo hi; logand_mask (get_bitfield_raw x lo hi) (hi - lo); M.lemma_mod_lt x (pow2 (hi - lo)) let get_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Tot (ubitfield tot (hi - lo)) = get_bitfield_raw_bounded x lo hi; get_bitfield_raw x lo hi let nth_get_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) (i: nat {i < tot}) : Lemma (nth (get_bitfield x lo hi) i == (i < hi - lo && nth x (i + lo))) = nth_get_bitfield_raw x lo hi i let get_bitfield_logor (#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Lemma (get_bitfield (x `U.logor` y) lo hi == get_bitfield x lo hi `U.logor` get_bitfield y lo hi) = eq_nth (get_bitfield (x `U.logor` y) lo hi) (get_bitfield x lo hi `U.logor` get_bitfield y lo hi) (fun i -> nth_get_bitfield (x `U.logor` y) lo hi i; nth_get_bitfield x lo hi i; nth_get_bitfield y lo hi i ) let get_bitfield_logxor (#tot: pos) (x y: U.uint_t tot) (lo: nat) (hi: nat {lo <= hi /\ hi <= tot}) : Lemma (get_bitfield (x `U.logxor` y) lo hi == get_bitfield x lo hi `U.logxor` get_bitfield y lo hi) = eq_nth (get_bitfield (x `U.logxor` y) lo hi) (get_bitfield x lo hi `U.logxor` get_bitfield y lo hi) (fun i -> nth_get_bitfield (x `U.logxor` y) lo hi i; nth_get_bitfield x lo hi i; nth_get_bitfield y lo hi i ) #push-options "--z3rlimit 16" let logor_disjoint (#n: pos) (a: U.uint_t n) (b: U.uint_t n) (m: nat {m <= n}) : Lemma (requires ( a % pow2 m == 0 /\ b < pow2 m )) (ensures (U.logor #n a b == a + b)) = if m = 0 then U.logor_lemma_1 a else if m = n then begin M.modulo_lemma a (pow2 n); U.logor_commutative a b; U.logor_lemma_1 b end else U.logor_disjoint a b m #pop-options let bitfield_mask_mod_pow2_lo (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (m: nat {m <= lo}) : Lemma (bitfield_mask tot lo hi % pow2 m == 0) = M.pow2_multiplication_modulo_lemma_1 (pow2 (hi - lo) - 1) m lo let bitfield_mask_lt_pow2_hi (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Lemma (bitfield_mask tot lo hi < pow2 hi) = M.pow2_le_compat tot hi; M.pow2_plus (hi - lo) lo inline_for_extraction let not_bitfield_mask (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) : Tot (x: U.uint_t tot {x == U.lognot (bitfield_mask tot lo hi)}) = [@inline_let] let a = bitfield_mask tot hi tot in [@inline_let] let b = bitfield_mask tot 0 lo in [@inline_let] let _ = bitfield_mask_mod_pow2_lo tot hi tot lo; bitfield_mask_lt_pow2_hi tot 0 lo; logor_disjoint a b lo; eq_nth (a `U.logor` b) (U.lognot (bitfield_mask tot lo hi)) (fun i -> nth_bitfield_mask tot hi tot i; nth_bitfield_mask tot 0 lo i; nth_bitfield_mask tot lo hi i ) in normalize_term (a + b) let nth_not_bitfield_mask (tot: pos) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (i: nat {i < tot}) : Lemma (nth (not_bitfield_mask tot lo hi) i == (i < lo || hi <= i)) = nth_lognot (bitfield_mask tot lo hi) i; nth_bitfield_mask tot lo hi i let set_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) : Tot (U.uint_t tot) = (x `U.logand` not_bitfield_mask tot lo hi) `U.logor` (v `U.shift_left` lo) let nth_set_bitfield (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat { lo <= hi /\ hi <= tot }) (v: ubitfield tot (hi - lo)) (i: nat {i < tot}) : Lemma (nth (set_bitfield x lo hi v) i == (if lo <= i && i < hi then nth v (i - lo) else nth x i)) = let y = nth (set_bitfield x lo hi v) i in nth_logor (x `U.logand` not_bitfield_mask tot lo hi) (v `U.shift_left` lo) i; assert (y == (nth (x `U.logand` not_bitfield_mask tot lo hi) i || nth (v `U.shift_left` lo) i)); nth_logand x (not_bitfield_mask tot lo hi) i; assert (y == ((nth x i && nth (not_bitfield_mask tot lo hi) i) || nth (v `U.shift_left` lo) i)); nth_not_bitfield_mask tot lo hi i; assert (y == ((nth x i && (i < lo || hi <= i)) || nth (v `U.shift_left` lo) i)); nth_shift_left v lo i; assert (y == ((nth x i && (i < lo || hi <= i)) || (lo <= i && nth v (i - lo)))); if (lo <= i && i < hi) then assert (y == nth v (i - lo)) else if (i < hi) then assert (y == nth x i) else begin nth_le_pow2_m v (hi - lo) (i - lo); assert (y == nth x i) end; assert (y == (if lo <= i && i < hi then nth v (i - lo) else nth x i))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.BitFields.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": false, "full_module": "LowParse", "short_module": null }, { "abbrev": false, "full_module": "LowParse", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt.uint_t tot -> lo: Prims.nat -> hi: Prims.nat{lo <= hi /\ hi <= tot} -> v: LowParse.BitFields.ubitfield tot (hi - lo) -> FStar.Pervasives.Lemma (ensures LowParse.BitFields.get_bitfield (LowParse.BitFields.set_bitfield x lo hi v) lo hi == v)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.UInt.uint_t", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowParse.BitFields.ubitfield", "Prims.op_Subtraction", "LowParse.BitFields.eq_nth", "LowParse.BitFields.get_bitfield", "LowParse.BitFields.set_bitfield", "Prims.op_LessThan", "LowParse.BitFields.nth_set_bitfield", "Prims.op_Addition", "Prims.bool", "LowParse.BitFields.nth_le_pow2_m", "Prims.unit", "LowParse.BitFields.nth_get_bitfield", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let get_bitfield_set_bitfield_same (#tot: pos) (x: U.uint_t tot) (lo: nat) (hi: nat{lo <= hi /\ hi <= tot}) (v: ubitfield tot (hi - lo)) : Lemma (get_bitfield (set_bitfield x lo hi v) lo hi == v) =
eq_nth (get_bitfield (set_bitfield x lo hi v) lo hi) v (fun i -> nth_get_bitfield (set_bitfield x lo hi v) lo hi i; if i < hi - lo then nth_set_bitfield x lo hi v (i + lo) else nth_le_pow2_m v (hi - lo) i)
false
Hacl.Impl.Lib.fst
Hacl.Impl.Lib.fill_elems4
val fill_elems4: fill_elems_st
val fill_elems4: fill_elems_st
let fill_elems4 #t #a h0 n output refl footprint spec impl = [@inline_let] let k = n /. 4ul in let tmp = sub output 0ul (4ul *! k) in fill_blocks4 #t #a h0 k tmp refl footprint spec (fun i -> impl i); let h1 = ST.get () in assert (4 * v k + v (n -! 4ul *! k) = v n); B.modifies_buffer_elim (B.gsub #t output (4ul *! k) (n -! 4ul *! k)) (footprint (4 * v k) |+| loc tmp) h0 h1; assert (modifies (footprint (4 * v k) |+| loc (gsub output 0ul (4ul *! k))) h0 h1); let inv (h:mem) (i:nat{4 * v k <= i /\ i <= v n}) = modifies (footprint i |+| loc (gsub output 0ul (size i))) h0 h /\ (let (c, res) = Loops.repeat_right (v n / 4 * 4) i (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl h1 (4 * v k), as_seq h1 (gsub output 0ul (4ul *! k))) in refl h i == c /\ as_seq h (gsub output 0ul (size i)) == res) in Loops.eq_repeat_right (v n / 4 * 4) (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl h1 (4 * v k), as_seq h1 (gsub output 0ul (4ul *! k))); Lib.Loops.for (k *! 4ul) n inv (fun i -> impl i; let h = ST.get () in assert (v (i +! 1ul) = v i + 1); FStar.Seq.lemma_split (as_seq h (gsub output 0ul (i +! 1ul))) (v i); Loops.unfold_repeat_right (v n / 4 * 4) (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl h1 (4 * v k), as_seq h1 (gsub output 0ul (4ul *! k))) (v i) ); S.lemma_generate_elems4 (v n) (v n) (spec h0) (refl h0 0)
{ "file_name": "code/bignum/Hacl.Impl.Lib.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 59, "end_line": 153, "start_col": 0, "start_line": 125 }
module Hacl.Impl.Lib open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators module S = Hacl.Spec.Lib #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let fill_elems_st = #t:Type0 -> #a:Type0 -> h0:mem -> n:size_t -> output:lbuffer t n -> refl:(mem -> i:size_nat{i <= v n} -> GTot a) -> footprint:(i:size_nat{i <= v n} -> GTot (l:B.loc{B.loc_disjoint l (loc output) /\ B.address_liveness_insensitive_locs `B.loc_includes` l})) -> spec:(mem -> GTot (i:size_nat{i < v n} -> a -> a & t)) -> impl:(i:size_t{v i < v n} -> Stack unit (requires fun h -> modifies (footprint (v i) |+| loc (gsub output 0ul i)) h0 h) (ensures fun h1 _ h2 -> (let block1 = gsub output i 1ul in let c, e = spec h0 (v i) (refl h1 (v i)) in refl h2 (v i + 1) == c /\ LSeq.index (as_seq h2 block1) 0 == e /\ footprint (v i + 1) `B.loc_includes` footprint (v i) /\ modifies (footprint (v i + 1) |+| (loc block1)) h1 h2))) -> Stack unit (requires fun h -> h0 == h /\ live h output) (ensures fun _ _ h1 -> modifies (footprint (v n) |+| loc output) h0 h1 /\ (let s, o = S.generate_elems (v n) (v n) (spec h0) (refl h0 0) in refl h1 (v n) == s /\ as_seq #_ #t h1 output == o)) inline_for_extraction noextract val fill_elems : fill_elems_st let fill_elems #t #a h0 n output refl footprint spec impl = [@inline_let] let refl' h (i:nat{i <= v n}) : GTot (S.generate_elem_a t a (v n) i) = refl h i, as_seq h (gsub output 0ul (size i)) in [@inline_let] let footprint' i = footprint i |+| loc (gsub output 0ul (size i)) in [@inline_let] let spec' h0 = S.generate_elem_f (v n) (spec h0) in let h0 = ST.get () in loop h0 n (S.generate_elem_a t a (v n)) refl' footprint' spec' (fun i -> Loops.unfold_repeat_gen (v n) (S.generate_elem_a t a (v n)) (spec' h0) (refl' h0 0) (v i); impl i; let h = ST.get() in FStar.Seq.lemma_split (as_seq h (gsub output 0ul (i +! 1ul))) (v i) ); let h1 = ST.get () in assert (refl' h1 (v n) == Loops.repeat_gen (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl' h0 0)) inline_for_extraction noextract val fill_blocks4: #t:Type0 -> #a:Type0 -> h0:mem -> n4:size_t{4 * v n4 <= max_size_t} -> output:lbuffer t (4ul *! n4) -> refl:(mem -> i:size_nat{i <= 4 * v n4} -> GTot a) -> footprint:(i:size_nat{i <= 4 * v n4} -> GTot (l:B.loc{B.loc_disjoint l (loc output) /\ B.address_liveness_insensitive_locs `B.loc_includes` l})) -> spec:(mem -> GTot (i:size_nat{i < 4 * v n4} -> a -> a & t)) -> impl:(i:size_t{v i < 4 * v n4} -> Stack unit (requires fun h -> modifies (footprint (v i) |+| loc (gsub output 0ul i)) h0 h) (ensures fun h1 _ h2 -> (let block1 = gsub output i 1ul in let c, e = spec h0 (v i) (refl h1 (v i)) in refl h2 (v i + 1) == c /\ LSeq.index (as_seq h2 block1) 0 == e /\ footprint (v i + 1) `B.loc_includes` footprint (v i) /\ modifies (footprint (v i + 1) |+| (loc block1)) h1 h2))) -> Stack unit (requires fun h -> h0 == h /\ live h output) (ensures fun _ _ h1 -> modifies (footprint (4 * v n4) |+| loc output) h0 h1 /\ (let s, o = LSeq.generate_blocks 4 (v n4) (v n4) (Loops.fixed_a a) (S.generate_blocks4_f #t #a (v n4) (spec h0)) (refl h0 0) in refl h1 (4 * v n4) == s /\ as_seq #_ #t h1 output == o)) let fill_blocks4 #t #a h0 n4 output refl footprint spec impl = fill_blocks h0 4ul n4 output (Loops.fixed_a a) (fun h i -> refl h (4 * i)) (fun i -> footprint (4 * i)) (fun h0 -> S.generate_blocks4_f #t #a (v n4) (spec h0)) (fun i -> let h1 = ST.get () in impl (4ul *! i); impl (4ul *! i +! 1ul); impl (4ul *! i +! 2ul); impl (4ul *! i +! 3ul); let h2 = ST.get () in assert ( let c0, e0 = spec h0 (4 * v i) (refl h1 (4 * v i)) in let c1, e1 = spec h0 (4 * v i + 1) c0 in let c2, e2 = spec h0 (4 * v i + 2) c1 in let c3, e3 = spec h0 (4 * v i + 3) c2 in let res = LSeq.create4 e0 e1 e2 e3 in LSeq.create4_lemma e0 e1 e2 e3; let res1 = LSeq.sub (as_seq h2 output) (4 * v i) 4 in refl h2 (4 * v i + 4) == c3 /\ (LSeq.eq_intro res res1; res1 `LSeq.equal` res)) ) inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Lib.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Lib.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Lib", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": 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
Hacl.Impl.Lib.fill_elems_st
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "LowStar.Monotonic.Buffer.loc", "Prims.l_and", "LowStar.Monotonic.Buffer.loc_disjoint", "Lib.Buffer.loc", "Lib.Buffer.MUT", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "Prims.op_LessThan", "FStar.Pervasives.Native.tuple2", "Prims.unit", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.gsub", "FStar.UInt32.__uint_to_t", "Prims.eq2", "Prims.op_Addition", "Lib.Sequence.index", "Lib.Buffer.as_seq", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Hacl.Spec.Lib.lemma_generate_elems4", "Lib.Loops.for", "Lib.IntTypes.op_Star_Bang", "Lib.LoopCombinators.unfold_repeat_right", "FStar.Mul.op_Star", "Prims.op_Division", "Hacl.Spec.Lib.generate_elem_a", "Hacl.Spec.Lib.generate_elem_f", "FStar.Pervasives.Native.Mktuple2", "Lib.Sequence.seq", "Prims.nat", "Lib.Sequence.length", "FStar.Seq.Properties.lemma_split", "Lib.IntTypes.op_Plus_Bang", "Prims._assert", "Prims.op_Equality", "Prims.int", "FStar.HyperStack.ST.get", "Lib.LoopCombinators.eq_repeat_right", "Prims.op_Multiply", "Prims.logical", "Lib.IntTypes.size", "Prims.l_or", "FStar.Seq.Base.length", "Lib.LoopCombinators.repeat_right", "LowStar.Monotonic.Buffer.modifies_buffer_elim", "LowStar.Buffer.trivial_preorder", "LowStar.Buffer.gsub", "Lib.IntTypes.op_Subtraction_Bang", "Hacl.Impl.Lib.fill_blocks4", "Lib.IntTypes.mul", "Lib.Buffer.sub", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Slash_Dot" ]
[]
false
false
false
true
false
let fill_elems4 #t #a h0 n output refl footprint spec impl =
[@@ inline_let ]let k = n /. 4ul in let tmp = sub output 0ul (4ul *! k) in fill_blocks4 #t #a h0 k tmp refl footprint spec (fun i -> impl i); let h1 = ST.get () in assert (4 * v k + v (n -! 4ul *! k) = v n); B.modifies_buffer_elim (B.gsub #t output (4ul *! k) (n -! 4ul *! k)) (footprint (4 * v k) |+| loc tmp) h0 h1; assert (modifies (footprint (4 * v k) |+| loc (gsub output 0ul (4ul *! k))) h0 h1); let inv (h: mem) (i: nat{4 * v k <= i /\ i <= v n}) = modifies (footprint i |+| loc (gsub output 0ul (size i))) h0 h /\ (let c, res = Loops.repeat_right ((v n / 4) * 4) i (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl h1 (4 * v k), as_seq h1 (gsub output 0ul (4ul *! k))) in refl h i == c /\ as_seq h (gsub output 0ul (size i)) == res) in Loops.eq_repeat_right ((v n / 4) * 4) (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl h1 (4 * v k), as_seq h1 (gsub output 0ul (4ul *! k))); Lib.Loops.for (k *! 4ul) n inv (fun i -> impl i; let h = ST.get () in assert (v (i +! 1ul) = v i + 1); FStar.Seq.lemma_split (as_seq h (gsub output 0ul (i +! 1ul))) (v i); Loops.unfold_repeat_right ((v n / 4) * 4) (v n) (S.generate_elem_a t a (v n)) (S.generate_elem_f (v n) (spec h0)) (refl h1 (4 * v k), as_seq h1 (gsub output 0ul (4ul *! k))) (v i)); S.lemma_generate_elems4 (v n) (v n) (spec h0) (refl h0 0)
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.null_var
val null_var (v: var) : term
val null_var (v: var) : term
let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default}
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 46, "end_line": 110, "start_col": 0, "start_line": 109 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r}
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
v: Pulse.Syntax.Base.var -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.var", "Pulse.Syntax.Pure.tm_var", "Pulse.Syntax.Base.Mknm", "Pulse.Syntax.Base.ppname_default", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let null_var (v: var) : term =
tm_var ({ nm_index = v; nm_ppname = ppname_default })
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.max_additional_input_length
val max_additional_input_length:n: size_t{v n == S.max_additional_input_length}
val max_additional_input_length:n: size_t{v n == S.max_additional_input_length}
let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length)
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 79, "start_col": 0, "start_line": 77 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length)
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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
n: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v n == Spec.HMAC_DRBG.max_additional_input_length}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Spec.HMAC_DRBG.max_additional_input_length", "Lib.IntTypes.mk_int", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_LessThan", "Prims.pow2" ]
[]
false
false
false
false
false
let max_additional_input_length:n: size_t{v n == S.max_additional_input_length} =
assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length)
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.reseed_st
val reseed_st : a: EverCrypt.DRBG.supported_alg -> Type0
let reseed_st (a:supported_alg) = st:state a -> additional_input:B.buffer uint8 -> additional_input_len:size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 additional_input /\ disjoint_st st additional_input h0 /\ B.length additional_input = v additional_input_len) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v additional_input_len <= S.max_additional_input_length /\ footprint st h0 == footprint st h1 /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ B.modifies (footprint st h0) h0 h1 /\ (exists entropy_input. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ repr st h1 == S.reseed (repr st h0) entropy_input (B.as_seq h0 additional_input)))
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 76, "end_line": 258, "start_col": 0, "start_line": 234 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0 inline_for_extraction noextract let state a = B.pointer (state_s a) inline_for_extraction noextract val freeable_s: #a:supported_alg -> st:state_s a -> Type0 inline_for_extraction noextract let freeable (#a:supported_alg) (st:state a) (h:HS.mem) = B.freeable st /\ freeable_s (B.deref h st) val footprint_s: #a:supported_alg -> state_s a -> GTot B.loc let footprint (#a:supported_alg) (st:state a) (h:HS.mem) = B.loc_union (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) inline_for_extraction noextract val invariant_s: #a:supported_alg -> state_s a -> HS.mem -> Type0 inline_for_extraction noextract let invariant (#a:supported_alg) (st:state a) (h:HS.mem) = B.live h st /\ B.loc_disjoint (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) /\ invariant_s (B.deref h st) h inline_for_extraction noextract let disjoint_st (#t:Type) (#a:supported_alg) (st:state a) (b:B.buffer t) (h:HS.mem) = B.loc_disjoint (footprint st h) (B.loc_buffer b) val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a) /// TR: the following pattern is necessary because, if we generically /// add such a pattern directly on `loc_includes_union_l`, then /// verification will blowup whenever both sides of `loc_includes` are /// `loc_union`s. We would like to break all unions on the /// right-hand-side of `loc_includes` first, using /// `loc_includes_union_r`. Here the pattern is on `footprint_s`, /// because we already expose the fact that `footprint` is a /// `loc_union`. (In other words, the pattern should be on every /// smallest location that is not exposed to be a `loc_union`.) /// val loc_includes_union_l_footprint_s: #a:supported_alg -> l1:B.loc -> l2:B.loc -> st:state_s a -> Lemma (requires B.loc_includes l1 (footprint_s st) \/ B.loc_includes l2 (footprint_s st)) (ensures B.loc_includes (B.loc_union l1 l2) (footprint_s st)) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s st))] /// Needed to prove that the footprint is disjoint from any fresh location val invariant_loc_in_footprint: #a:supported_alg -> st:state a -> h:HS.mem -> Lemma (requires invariant st h) (ensures B.loc_in (footprint st h) h) [SMTPat (invariant st h)] val frame_invariant: #a:supported_alg -> l:B.loc -> st:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires invariant st h0 /\ B.loc_disjoint l (footprint st h0) /\ B.modifies l h0 h1) (ensures invariant st h1 /\ repr st h0 == repr st h1) inline_for_extraction noextract let preserves_freeable #a (st:state a) (h0 h1:HS.mem) = freeable st h0 ==> freeable st h1 inline_for_extraction val alloca: a:supported_alg -> StackInline (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st h1)) /\ invariant st h1) val create_in: a:supported_alg -> r:HS.rid -> ST (state a) (requires fun _ -> is_eternal_region r) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint st h1)) /\ invariant st h1 /\ freeable st h1) (** @type: true *) [@@ Comment "Create a DRBG state. @param a Hash algorithm to use. The possible instantiations are ... * `Spec_Hash_Definitions_SHA2_256`, * `Spec_Hash_Definitions_SHA2_384`, * `Spec_Hash_Definitions_SHA2_512`, and * `Spec_Hash_Definitions_SHA1`. @return DRBG state. Needs to be freed via `EverCrypt_DRBG_uninstantiate`."] val create: a:supported_alg -> ST (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ invariant st h1 /\ freeable st h1) inline_for_extraction noextract let instantiate_st (a:supported_alg) = st:state a -> personalization_string:B.buffer uint8 -> personalization_string_len:size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 personalization_string /\ disjoint_st st personalization_string h0 /\ B.length personalization_string = v personalization_string_len) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v personalization_string_len <= S.max_personalization_string_length /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ footprint st h0 == footprint st h1 /\ B.modifies (footprint st h0) h0 h1 /\ (exists entropy_input nonce. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ S.min_length a / 2 <= Seq.length nonce /\ Seq.length nonce <= S.max_length /\ repr st h1 == S.instantiate entropy_input nonce (B.as_seq h0 personalization_string)))
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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: EverCrypt.DRBG.supported_alg -> Type0
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "EverCrypt.DRBG.state", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size_t", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverCrypt.DRBG.invariant", "LowStar.Monotonic.Buffer.live", "LowStar.Buffer.trivial_preorder", "EverCrypt.DRBG.disjoint_st", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "LowStar.Monotonic.Buffer.length", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Prims.op_Negation", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.op_LessThanOrEqual", "Spec.HMAC_DRBG.max_additional_input_length", "Prims.eq2", "LowStar.Monotonic.Buffer.loc", "EverCrypt.DRBG.footprint", "EverCrypt.DRBG.preserves_freeable", "Prims.l_Exists", "FStar.Seq.Base.seq", "Spec.HMAC_DRBG.min_length", "FStar.Seq.Base.length", "Spec.HMAC_DRBG.max_length", "Spec.HMAC_DRBG.state", "EverCrypt.DRBG.repr", "Spec.HMAC_DRBG.reseed", "LowStar.Monotonic.Buffer.as_seq", "Prims.unit", "Spec.HMAC_DRBG.hmac_input_bound" ]
[]
false
false
false
true
true
let reseed_st (a: supported_alg) =
st: state a -> additional_input: B.buffer uint8 -> additional_input_len: size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 additional_input /\ disjoint_st st additional_input h0 /\ B.length additional_input = v additional_input_len) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v additional_input_len <= S.max_additional_input_length /\ footprint st h0 == footprint st h1 /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ B.modifies (footprint st h0) h0 h1 /\ (exists entropy_input. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ repr st h1 == S.reseed (repr st h0) entropy_input (B.as_seq h0 additional_input)))
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.mk_bvar
val mk_bvar (s: string) (r: Range.range) (i: index) : term
val mk_bvar (s: string) (r: Range.range) (i: index) : term
let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r}
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 64, "end_line": 107, "start_col": 0, "start_line": 106 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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: Prims.string -> r: FStar.Range.range -> i: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "FStar.Range.range", "Pulse.Syntax.Base.index", "Pulse.Syntax.Pure.tm_bvar", "Pulse.Syntax.Base.Mkbv", "Pulse.Syntax.Base.mk_ppname", "FStar.Reflection.Typing.seal_pp_name", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let mk_bvar (s: string) (r: Range.range) (i: index) : term =
tm_bvar ({ bv_index = i; bv_ppname = mk_ppname (RT.seal_pp_name s) r })
false
EverCrypt.DRBG.fsti
EverCrypt.DRBG.generate_st
val generate_st : a: EverCrypt.DRBG.supported_alg -> Type0
let generate_st (a:supported_alg) = output:B.buffer uint8 -> st:state a -> n:size_t -> additional_input:B.buffer uint8 -> additional_input_len:size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 output /\ B.live h0 additional_input /\ disjoint_st st output h0 /\ disjoint_st st additional_input h0 /\ B.disjoint output additional_input /\ B.length additional_input = v additional_input_len /\ v n = B.length output) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v n <= S.max_output_length /\ v additional_input_len <= S.max_additional_input_length /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ footprint st h0 == footprint st h1 /\ B.modifies (B.loc_union (B.loc_buffer output) (footprint st h0)) h0 h1 /\ (exists entropy_input. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ (let st1 = S.reseed (repr st h0) entropy_input (B.as_seq h0 additional_input) in match S.generate st1 (v n) (B.as_seq h0 additional_input) with | None -> False // Always reseeds, so generation cannot fail | Some (out, st_) -> repr st h1 == st_ /\ B.as_seq h1 output == out)))
{ "file_name": "providers/evercrypt/EverCrypt.DRBG.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 295, "start_col": 0, "start_line": 262 }
module EverCrypt.DRBG open FStar.HyperStack.ST open Lib.IntTypes open Spec.Hash.Definitions module HS = FStar.HyperStack module B = LowStar.Buffer module S = Spec.HMAC_DRBG #set-options "--max_ifuel 0 --max_fuel 0" /// HMAC-DRBG /// /// See 10.1.2 and B.2 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf /// /// This module implements /// - HMAC_DRBG_Instantiate_function /// - HMAC_DRBG_Reseed_function /// - HMAC_DRBG_Generate_function /// - HMAC_DRBG_Uninstantiate_function /// /// Internally, it uses Lib.RandomBuffer.System as the Get_entropy_input function, /// for instantiation, reseeding, and prediction resistance. /// /// - Supports SHA-1, SHA2-256, SHA2-384 and SHA2-512 /// /// - Supports reseeding /// /// - Supports optional personalization_string for instantiation /// /// - Supports optional additional_input for reseeding and generation /// /// - Always provides prediction resistance (i.e. reseeds before generation) /// /// - The internal state is (Key,V,reseed_counter) /// /// - The security_strength is the HMAC-strength of the hash algorithm as per p.54 of /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf /// /// - The minimum entropy for instantiation is 3/2 * security_strength. /// - entropy_input must have at least security_strength bits. /// - nonce must have at least 1/2 security_strength bits. /// - entropy_input and nonce can have at most max_length = 2^16 bits. /// /// - At most max_number_of_bits_per_request = 2^16 bits can be generated per request. /// Some duplication from Hacl.HMAC_DRBG because we don't want clients to depend on it unfold let supported_alg = S.supported_alg //[@ CMacro ] let reseed_interval: n:size_t{v n == S.reseed_interval} = assert_norm (S.reseed_interval < pow2 32); normalize_term (mk_int S.reseed_interval) //[@ CMacro ] let max_output_length: n:size_t{v n == S.max_output_length} = assert_norm (S.max_output_length < pow2 32); normalize_term (mk_int S.max_output_length) //[@ CMacro ] let max_length: n:size_t{v n == S.max_length} = assert_norm (S.max_length < pow2 32); normalize_term (mk_int S.max_length) //[@ CMacro ] let max_personalization_string_length: n:size_t{v n == S.max_personalization_string_length} = assert_norm (S.max_personalization_string_length < pow2 32); normalize_term (mk_int S.max_personalization_string_length) //[@ CMacro ] let max_additional_input_length: n:size_t{v n == S.max_additional_input_length} = assert_norm (S.max_additional_input_length < pow2 32); normalize_term (mk_int S.max_additional_input_length) let min_length (a:supported_alg) : n:size_t{v n == S.min_length a} = assert_norm (S.min_length a < pow2 32); match a with | SHA1 -> normalize_term (mk_int (S.min_length SHA1)) | SHA2_256 | SHA2_384 | SHA2_512 -> normalize_term (mk_int (S.min_length SHA2_256)) /// This has a @CAbstractStruct attribute in the implementation. /// See https://github.com/FStarLang/karamel/issues/153 /// /// It instructs KaRaMeL to include only a forward-declarartion /// in the header file, forcing code to always use `state_s` abstractly /// through a pointer. inline_for_extraction noextract val state_s: supported_alg -> Type0 inline_for_extraction noextract let state a = B.pointer (state_s a) inline_for_extraction noextract val freeable_s: #a:supported_alg -> st:state_s a -> Type0 inline_for_extraction noextract let freeable (#a:supported_alg) (st:state a) (h:HS.mem) = B.freeable st /\ freeable_s (B.deref h st) val footprint_s: #a:supported_alg -> state_s a -> GTot B.loc let footprint (#a:supported_alg) (st:state a) (h:HS.mem) = B.loc_union (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) inline_for_extraction noextract val invariant_s: #a:supported_alg -> state_s a -> HS.mem -> Type0 inline_for_extraction noextract let invariant (#a:supported_alg) (st:state a) (h:HS.mem) = B.live h st /\ B.loc_disjoint (B.loc_addr_of_buffer st) (footprint_s (B.deref h st)) /\ invariant_s (B.deref h st) h inline_for_extraction noextract let disjoint_st (#t:Type) (#a:supported_alg) (st:state a) (b:B.buffer t) (h:HS.mem) = B.loc_disjoint (footprint st h) (B.loc_buffer b) val repr: #a:supported_alg -> st:state a -> h:HS.mem -> GTot (S.state a) /// TR: the following pattern is necessary because, if we generically /// add such a pattern directly on `loc_includes_union_l`, then /// verification will blowup whenever both sides of `loc_includes` are /// `loc_union`s. We would like to break all unions on the /// right-hand-side of `loc_includes` first, using /// `loc_includes_union_r`. Here the pattern is on `footprint_s`, /// because we already expose the fact that `footprint` is a /// `loc_union`. (In other words, the pattern should be on every /// smallest location that is not exposed to be a `loc_union`.) /// val loc_includes_union_l_footprint_s: #a:supported_alg -> l1:B.loc -> l2:B.loc -> st:state_s a -> Lemma (requires B.loc_includes l1 (footprint_s st) \/ B.loc_includes l2 (footprint_s st)) (ensures B.loc_includes (B.loc_union l1 l2) (footprint_s st)) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s st))] /// Needed to prove that the footprint is disjoint from any fresh location val invariant_loc_in_footprint: #a:supported_alg -> st:state a -> h:HS.mem -> Lemma (requires invariant st h) (ensures B.loc_in (footprint st h) h) [SMTPat (invariant st h)] val frame_invariant: #a:supported_alg -> l:B.loc -> st:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires invariant st h0 /\ B.loc_disjoint l (footprint st h0) /\ B.modifies l h0 h1) (ensures invariant st h1 /\ repr st h0 == repr st h1) inline_for_extraction noextract let preserves_freeable #a (st:state a) (h0 h1:HS.mem) = freeable st h0 ==> freeable st h1 inline_for_extraction val alloca: a:supported_alg -> StackInline (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint st h1)) /\ invariant st h1) val create_in: a:supported_alg -> r:HS.rid -> ST (state a) (requires fun _ -> is_eternal_region r) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint st h1)) /\ invariant st h1 /\ freeable st h1) (** @type: true *) [@@ Comment "Create a DRBG state. @param a Hash algorithm to use. The possible instantiations are ... * `Spec_Hash_Definitions_SHA2_256`, * `Spec_Hash_Definitions_SHA2_384`, * `Spec_Hash_Definitions_SHA2_512`, and * `Spec_Hash_Definitions_SHA1`. @return DRBG state. Needs to be freed via `EverCrypt_DRBG_uninstantiate`."] val create: a:supported_alg -> ST (state a) (requires fun _ -> True) (ensures fun h0 st h1 -> B.modifies B.loc_none h0 h1 /\ B.fresh_loc (footprint st h1) h0 h1 /\ invariant st h1 /\ freeable st h1) inline_for_extraction noextract let instantiate_st (a:supported_alg) = st:state a -> personalization_string:B.buffer uint8 -> personalization_string_len:size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 personalization_string /\ disjoint_st st personalization_string h0 /\ B.length personalization_string = v personalization_string_len) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v personalization_string_len <= S.max_personalization_string_length /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ footprint st h0 == footprint st h1 /\ B.modifies (footprint st h0) h0 h1 /\ (exists entropy_input nonce. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ S.min_length a / 2 <= Seq.length nonce /\ Seq.length nonce <= S.max_length /\ repr st h1 == S.instantiate entropy_input nonce (B.as_seq h0 personalization_string))) inline_for_extraction noextract let reseed_st (a:supported_alg) = st:state a -> additional_input:B.buffer uint8 -> additional_input_len:size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 additional_input /\ disjoint_st st additional_input h0 /\ B.length additional_input = v additional_input_len) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v additional_input_len <= S.max_additional_input_length /\ footprint st h0 == footprint st h1 /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ B.modifies (footprint st h0) h0 h1 /\ (exists entropy_input. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ repr st h1 == S.reseed (repr st h0) entropy_input (B.as_seq h0 additional_input)))
{ "checked_file": "/", "dependencies": [ "Spec.HMAC_DRBG.fsti.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.DRBG.fsti" }
[ { "abbrev": true, "full_module": "Spec.HMAC_DRBG", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": 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: EverCrypt.DRBG.supported_alg -> Type0
Prims.Tot
[ "total" ]
[]
[ "EverCrypt.DRBG.supported_alg", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "EverCrypt.DRBG.state", "Lib.IntTypes.size_t", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverCrypt.DRBG.invariant", "LowStar.Monotonic.Buffer.live", "LowStar.Buffer.trivial_preorder", "EverCrypt.DRBG.disjoint_st", "LowStar.Monotonic.Buffer.disjoint", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "LowStar.Monotonic.Buffer.length", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Prims.op_Negation", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.op_LessThanOrEqual", "Spec.HMAC_DRBG.max_output_length", "Spec.HMAC_DRBG.max_additional_input_length", "EverCrypt.DRBG.preserves_freeable", "Prims.eq2", "LowStar.Monotonic.Buffer.loc", "EverCrypt.DRBG.footprint", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_buffer", "Prims.l_Exists", "FStar.Seq.Base.seq", "Spec.HMAC_DRBG.min_length", "FStar.Seq.Base.length", "Spec.HMAC_DRBG.max_length", "Spec.HMAC_DRBG.generate", "LowStar.Monotonic.Buffer.as_seq", "Prims.l_False", "Spec.Agile.HMAC.lbytes", "Spec.HMAC_DRBG.state", "EverCrypt.DRBG.repr", "Prims.logical", "Spec.HMAC_DRBG.reseed", "Prims.unit", "Spec.HMAC_DRBG.hmac_input_bound" ]
[]
false
false
false
true
true
let generate_st (a: supported_alg) =
output: B.buffer uint8 -> st: state a -> n: size_t -> additional_input: B.buffer uint8 -> additional_input_len: size_t -> Stack bool (requires fun h0 -> invariant st h0 /\ B.live h0 output /\ B.live h0 additional_input /\ disjoint_st st output h0 /\ disjoint_st st additional_input h0 /\ B.disjoint output additional_input /\ B.length additional_input = v additional_input_len /\ v n = B.length output) (ensures fun h0 b h1 -> S.hmac_input_bound a; if not b then B.modifies B.loc_none h0 h1 else v n <= S.max_output_length /\ v additional_input_len <= S.max_additional_input_length /\ invariant st h1 /\ preserves_freeable st h0 h1 /\ footprint st h0 == footprint st h1 /\ B.modifies (B.loc_union (B.loc_buffer output) (footprint st h0)) h0 h1 /\ (exists entropy_input. S.min_length a <= Seq.length entropy_input /\ Seq.length entropy_input <= S.max_length /\ (let st1 = S.reseed (repr st h0) entropy_input (B.as_seq h0 additional_input) in match S.generate st1 (v n) (B.as_seq h0 additional_input) with | None -> False | Some (out, st_) -> repr st h1 == st_ /\ B.as_seq h1 output == out)))
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.term_of_nvar
val term_of_nvar (x: nvar) : term
val term_of_nvar (x: nvar) : term
let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x}
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 116, "start_col": 0, "start_line": 115 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default}
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.nvar -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.nvar", "Pulse.Syntax.Pure.tm_var", "Pulse.Syntax.Base.Mknm", "FStar.Pervasives.Native.snd", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.var", "FStar.Pervasives.Native.fst", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let term_of_nvar (x: nvar) : term =
tm_var ({ nm_index = snd x; nm_ppname = fst x })
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.is_pure_app
val is_pure_app (t: term) : option (term & option qualifier & term)
val is_pure_app (t: term) : option (term & option qualifier & term)
let is_pure_app (t:term) : option (term & option qualifier & term) = match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_App hd (arg, q) -> let? hd = match readback_ty hd with | Some hd -> Some hd <: option term | _ -> None in let q = readback_qual q in let? arg = match readback_ty arg with | Some arg -> Some arg <: option term | _ -> None in Some (hd, q, arg) | _ -> None end | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 174, "start_col": 0, "start_line": 157 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x} let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x) let is_bvar (t:term) : option nat = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None end | _ -> None let is_var (t:term) : option nm = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_Var nv -> let nv_view = R.inspect_namedv nv in Some {nm_index=nv_view.uniq; nm_ppname=mk_ppname (nv_view.ppname) t.range} | _ -> None end | _ -> None let is_fvar (t:term) : option (R.name & list universe) = let open R in match t.t with | Tm_FStar host_term -> begin match inspect_ln host_term with | Tv_FVar fv -> Some (inspect_fv fv, []) | Tv_UInst fv us -> Some (inspect_fv fv, us) | _ -> None end | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option ((Pulse.Syntax.Base.term * FStar.Pervasives.Native.option Pulse.Syntax.Base.qualifier) * Pulse.Syntax.Base.term)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Syntax.Pure.op_let_Question", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.qualifier", "Pulse.Readback.readback_ty", "Prims.eq2", "Pulse.Elaborate.Pure.elab_term", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.Mktuple3", "Pulse.Readback.readback_qual", "FStar.Stubs.Reflection.V2.Data.term_view", "Pulse.Syntax.Base.term'" ]
[]
false
false
false
true
false
let is_pure_app (t: term) : option (term & option qualifier & term) =
match t.t with | Tm_FStar host_term -> (match R.inspect_ln host_term with | R.Tv_App hd (arg, q) -> let? hd = match readback_ty hd with | Some hd -> Some hd <: option term | _ -> None in let q = readback_qual q in let? arg = match readback_ty arg with | Some arg -> Some arg <: option term | _ -> None in Some (hd, q, arg) | _ -> None) | _ -> None
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.null_bvar
val null_bvar (i: index) : term
val null_bvar (i: index) : term
let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default}
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 47, "end_line": 113, "start_col": 0, "start_line": 112 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default}
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.index -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.index", "Pulse.Syntax.Pure.tm_bvar", "Pulse.Syntax.Base.Mkbv", "Pulse.Syntax.Base.ppname_default", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let null_bvar (i: index) : term =
tm_bvar ({ bv_index = i; bv_ppname = ppname_default })
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.is_bvar
val is_bvar (t: term) : option nat
val is_bvar (t: term) : option nat
let is_bvar (t:term) : option nat = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None end | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 130, "start_col": 0, "start_line": 120 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x} let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x)
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.bv", "FStar.Pervasives.Native.Some", "Prims.nat", "FStar.Stubs.Reflection.V2.Data.__proj__Mkbv_view__item__index", "FStar.Stubs.Reflection.V2.Data.bv_view", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_bv", "FStar.Stubs.Reflection.V2.Data.term_view", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.term'" ]
[]
false
false
false
true
false
let is_bvar (t: term) : option nat =
let open R in match t.t with | Tm_FStar host_term -> (match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None) | _ -> None
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_msg2_spec_def
val sha256_msg2_spec_def (src1 src2: quad32) : quad32
val sha256_msg2_spec_def (src1 src2: quad32) : quad32
let sha256_msg2_spec_def (src1 src2:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let w14 = uint_to_t src2.hi2 in let w15 = uint_to_t src2.hi3 in let w16 = add_mod (uint_to_t src1.lo0) (_sigma1 SHA2_256 w14) in let w17 = add_mod (uint_to_t src1.lo1) (_sigma1 SHA2_256 w15) in let w18 = add_mod (uint_to_t src1.hi2) (_sigma1 SHA2_256 w16) in let w19 = add_mod (uint_to_t src1.hi3) (_sigma1 SHA2_256 w17) in Mkfour (v w16) (v w17) (v w18) (v w19)
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 76, "start_col": 0, "start_line": 68 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2 let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h') let sha256_rnds2_spec_def (src1 src2 wk:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1,b1,c1,d1,e1,f1,g1,h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2,b2,c2,d2,e2,f2,g2,h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in dst [@"opaque_to_smt"] let sha256_rnds2_spec = opaque_make sha256_rnds2_spec_def irreducible let sha256_rnds2_spec_reveal = opaque_revealer (`%sha256_rnds2_spec) sha256_rnds2_spec sha256_rnds2_spec_def let sha256_msg1_spec_def (src1 src2:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let w4 = uint_to_t src2.lo0 in let w3 = uint_to_t src1.hi3 in let w2 = uint_to_t src1.hi2 in let w1 = uint_to_t src1.lo1 in let w0 = uint_to_t src1.lo0 in Mkfour (v (add_mod w0 (_sigma0 SHA2_256 w1))) (v (add_mod w1 (_sigma0 SHA2_256 w2))) (v (add_mod w2 (_sigma0 SHA2_256 w3))) (v (add_mod w3 (_sigma0 SHA2_256 w4))) [@"opaque_to_smt"] let sha256_msg1_spec = opaque_make sha256_msg1_spec_def irreducible let sha256_msg1_spec_reveal = opaque_revealer (`%sha256_msg1_spec) sha256_msg1_spec sha256_msg1_spec_def
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src1: Vale.Def.Types_s.quad32 -> src2: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Types_s.quad32", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "FStar.UInt32.v", "FStar.UInt32.t", "FStar.UInt32.add_mod", "FStar.UInt32.uint_to_t", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Spec.SHA2._sigma1", "Spec.Hash.Definitions.SHA2_256", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__lo0" ]
[]
false
false
false
true
false
let sha256_msg2_spec_def (src1 src2: quad32) : quad32 =
let open FStar.UInt32 in let w14 = uint_to_t src2.hi2 in let w15 = uint_to_t src2.hi3 in let w16 = add_mod (uint_to_t src1.lo0) (_sigma1 SHA2_256 w14) in let w17 = add_mod (uint_to_t src1.lo1) (_sigma1 SHA2_256 w15) in let w18 = add_mod (uint_to_t src1.hi2) (_sigma1 SHA2_256 w16) in let w19 = add_mod (uint_to_t src1.hi3) (_sigma1 SHA2_256 w17) in Mkfour (v w16) (v w17) (v w18) (v w19)
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.is_fvar
val is_fvar (t: term) : option (R.name & list universe)
val is_fvar (t: term) : option (R.name & list universe)
let is_fvar (t:term) : option (R.name & list universe) = let open R in match t.t with | Tm_FStar host_term -> begin match inspect_ln host_term with | Tv_FVar fv -> Some (inspect_fv fv, []) | Tv_UInst fv us -> Some (inspect_fv fv, us) | _ -> None end | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 155, "start_col": 0, "start_line": 146 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x} let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x) let is_bvar (t:term) : option nat = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None end | _ -> None let is_var (t:term) : option nm = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_Var nv -> let nv_view = R.inspect_namedv nv in Some {nm_index=nv_view.uniq; nm_ppname=mk_ppname (nv_view.ppname) t.range} | _ -> None end | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option (FStar.Stubs.Reflection.Types.name * Prims.list Pulse.Syntax.Base.universe)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.fv", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.Types.name", "Prims.list", "Pulse.Syntax.Base.universe", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Builtins.inspect_fv", "Prims.Nil", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Stubs.Reflection.V2.Data.term_view", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.term'" ]
[]
false
false
false
true
false
let is_fvar (t: term) : option (R.name & list universe) =
let open R in match t.t with | Tm_FStar host_term -> (match inspect_ln host_term with | Tv_FVar fv -> Some (inspect_fv fv, []) | Tv_UInst fv us -> Some (inspect_fv fv, us) | _ -> None) | _ -> None
false
Vale.X64.CryptoInstructions_s.fst
Vale.X64.CryptoInstructions_s.sha256_msg1_spec_def
val sha256_msg1_spec_def (src1 src2: quad32) : quad32
val sha256_msg1_spec_def (src1 src2: quad32) : quad32
let sha256_msg1_spec_def (src1 src2:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let w4 = uint_to_t src2.lo0 in let w3 = uint_to_t src1.hi3 in let w2 = uint_to_t src1.hi2 in let w1 = uint_to_t src1.lo1 in let w0 = uint_to_t src1.lo0 in Mkfour (v (add_mod w0 (_sigma0 SHA2_256 w1))) (v (add_mod w1 (_sigma0 SHA2_256 w2))) (v (add_mod w2 (_sigma0 SHA2_256 w3))) (v (add_mod w3 (_sigma0 SHA2_256 w4)))
{ "file_name": "vale/specs/hardware/Vale.X64.CryptoInstructions_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 64, "start_col": 0, "start_line": 54 }
module Vale.X64.CryptoInstructions_s open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Spec.Hash.Definitions open Spec.SHA2 friend Lib.IntTypes friend Spec.SHA2 let sha256_rnds2_spec_update (a b c d e f g h wk : word SHA2_256) = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))))) in let b' = a in let c' = b in let d' = c in let e' = add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))) in let f' = e in let g' = f in let h' = g in (a', b', c', d', e', f', g', h') let sha256_rnds2_spec_def (src1 src2 wk:quad32) : quad32 = let open FStar.UInt32 in // Interop with UInt-based SHA spec let a0 = uint_to_t src2.hi3 in let b0 = uint_to_t src2.hi2 in let c0 = uint_to_t src1.hi3 in let d0 = uint_to_t src1.hi2 in let e0 = uint_to_t src2.lo1 in let f0 = uint_to_t src2.lo0 in let g0 = uint_to_t src1.lo1 in let h0 = uint_to_t src1.lo0 in let wk0 = uint_to_t wk.lo0 in let wk1 = uint_to_t wk.lo1 in let a1,b1,c1,d1,e1,f1,g1,h1 = sha256_rnds2_spec_update a0 b0 c0 d0 e0 f0 g0 h0 wk0 in let a2,b2,c2,d2,e2,f2,g2,h2 = sha256_rnds2_spec_update a1 b1 c1 d1 e1 f1 g1 h1 wk1 in let dst = Mkfour (v f2) (v e2) (v b2) (v a2) in dst [@"opaque_to_smt"] let sha256_rnds2_spec = opaque_make sha256_rnds2_spec_def irreducible let sha256_rnds2_spec_reveal = opaque_revealer (`%sha256_rnds2_spec) sha256_rnds2_spec sha256_rnds2_spec_def
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Spec.SHA2.fst.checked", "Spec.SHA2.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.CryptoInstructions_s.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src1: Vale.Def.Types_s.quad32 -> src2: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Types_s.quad32", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "FStar.UInt32.v", "FStar.UInt32.add_mod", "Spec.SHA2._sigma0", "Spec.Hash.Definitions.SHA2_256", "FStar.UInt32.t", "FStar.UInt32.uint_to_t", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3" ]
[]
false
false
false
true
false
let sha256_msg1_spec_def (src1 src2: quad32) : quad32 =
let open FStar.UInt32 in let w4 = uint_to_t src2.lo0 in let w3 = uint_to_t src1.hi3 in let w2 = uint_to_t src1.hi2 in let w1 = uint_to_t src1.lo1 in let w0 = uint_to_t src1.lo0 in Mkfour (v (add_mod w0 (_sigma0 SHA2_256 w1))) (v (add_mod w1 (_sigma0 SHA2_256 w2))) (v (add_mod w2 (_sigma0 SHA2_256 w3))) (v (add_mod w3 (_sigma0 SHA2_256 w4)))
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.term_of_no_name_var
val term_of_no_name_var (x: var) : term
val term_of_no_name_var (x: var) : term
let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x)
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 26, "end_line": 118, "start_col": 0, "start_line": 117 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term =
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.var -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.var", "Pulse.Syntax.Pure.term_of_nvar", "Pulse.Syntax.Base.v_as_nv", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let term_of_no_name_var (x: var) : term =
term_of_nvar (v_as_nv x)
false
LowParse.Spec.BoundedInt.fsti
LowParse.Spec.BoundedInt.parse_bounded_integer_kind
val parse_bounded_integer_kind (i: integer_size) : Tot parser_kind
val parse_bounded_integer_kind (i: integer_size) : Tot parser_kind
let parse_bounded_integer_kind (i: integer_size) : Tot parser_kind = total_constant_size_parser_kind i
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 35, "end_line": 42, "start_col": 0, "start_line": 39 }
module LowParse.Spec.BoundedInt include LowParse.Spec.Base include LowParse.Spec.Int // for parse_u16_kind open FStar.Mul module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module E = FStar.Endianness (* bounded integers *) let integer_size : Type = (sz: nat { 1 <= sz /\ sz <= 4 } ) val integer_size_values (i: integer_size) : Lemma (i == 1 \/ i == 2 \/ i == 3 \/ i == 4) let bounded_integer_prop (i: integer_size) (u: U32.t) : GTot Type0 = U32.v u < (match i with 1 -> 256 | 2 -> 65536 | 3 -> 16777216 | 4 -> 4294967296) val bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) inline_for_extraction let bounded_integer (i: integer_size) : Tot Type = (u: U32.t { bounded_integer_prop i u } )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BoundedInt.fsti" }
[ { "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_kind
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.Base.total_constant_size_parser_kind", "LowParse.Spec.Base.parser_kind" ]
[]
false
false
false
true
false
let parse_bounded_integer_kind (i: integer_size) : Tot parser_kind =
total_constant_size_parser_kind i
false
LowParse.Spec.BoundedInt.fsti
LowParse.Spec.BoundedInt.in_bounds
val in_bounds (min max: nat) (x: U32.t) : GTot bool
val in_bounds (min max: nat) (x: U32.t) : GTot bool
let in_bounds (min: nat) (max: nat) (x: U32.t) : GTot bool = not (U32.v x < min || max < U32.v x)
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 38, "end_line": 173, "start_col": 0, "start_line": 168 }
module LowParse.Spec.BoundedInt include LowParse.Spec.Base include LowParse.Spec.Int // for parse_u16_kind open FStar.Mul module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module E = FStar.Endianness (* bounded integers *) let integer_size : Type = (sz: nat { 1 <= sz /\ sz <= 4 } ) val integer_size_values (i: integer_size) : Lemma (i == 1 \/ i == 2 \/ i == 3 \/ i == 4) let bounded_integer_prop (i: integer_size) (u: U32.t) : GTot Type0 = U32.v u < (match i with 1 -> 256 | 2 -> 65536 | 3 -> 16777216 | 4 -> 4294967296) val bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) inline_for_extraction let bounded_integer (i: integer_size) : Tot Type = (u: U32.t { bounded_integer_prop i u } ) inline_for_extraction let parse_bounded_integer_kind (i: integer_size) : Tot parser_kind = total_constant_size_parser_kind i val parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer 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 ) val serialize_bounded_integer (sz: integer_size) : Tot (serializer (parse_bounded_integer sz)) #push-options "--initial_fuel 8 --max_fuel 8 --initial_ifuel 0 --max_ifuel 0 --z3rlimit 20" val serialize_bounded_integer_spec (sz: integer_size) (x: bounded_integer sz) : Lemma (let (bx : nat {bx < pow2 (8 `FStar.Mul.op_Star` sz)}) = U32.v x in serialize (serialize_bounded_integer sz) x == E.n_to_be sz bx) val parse_bounded_integer_le (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) val parse_u16_le : parser parse_u16_kind U16.t val parse_u32_le : parser parse_u32_kind U32.t val serialize_bounded_integer_le (sz: integer_size) : Tot (serializer (parse_bounded_integer_le sz)) val serialize_u16_le : serializer parse_u16_le val serialize_u32_le : serializer parse_u32_le inline_for_extraction let log256' (n: nat) : Pure integer_size (requires (n > 0 /\ n < 4294967296)) (ensures (fun l -> pow2 (FStar.Mul.op_Star 8 (l - 1)) <= n /\ n < pow2 (FStar.Mul.op_Star 8 l) )) = [@inline_let] let _ = assert_norm (pow2 32 == 4294967296) in [@inline_let] let _ = assert (n < pow2 32) in [@inline_let] let z0 = 1 in [@inline_let] let z1 = 256 in [@inline_let] let _ = assert_norm (z1 == Prims.op_Multiply 256 z0) in [@inline_let] let l = 1 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z1) in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 (l - 1)) == z0) in if n < z1 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let z2 = 65536 in [@inline_let] let _ = assert_norm (z2 == Prims.op_Multiply 256 z1) in [@inline_let] let l = 2 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z2) in if n < z2 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let z3 = 16777216 in [@inline_let] let _ = assert_norm (z3 == Prims.op_Multiply 256 z2) in [@inline_let] let l = 3 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z3) in if n < z3 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let l = 4 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == Prims.op_Multiply 256 z3) in [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end end end
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BoundedInt.fsti" }
[ { "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": 8, "initial_ifuel": 0, "max_fuel": 8, "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat -> x: FStar.UInt32.t -> Prims.GTot Prims.bool
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "FStar.UInt32.t", "Prims.op_Negation", "Prims.op_BarBar", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.bool" ]
[]
false
false
false
false
false
let in_bounds (min max: nat) (x: U32.t) : GTot bool =
not (U32.v x < min || max < U32.v x)
false
LowParse.Spec.BoundedInt.fsti
LowParse.Spec.BoundedInt.bounded_integer_prop
val bounded_integer_prop (i: integer_size) (u: U32.t) : GTot Type0
val bounded_integer_prop (i: integer_size) (u: U32.t) : GTot Type0
let bounded_integer_prop (i: integer_size) (u: U32.t) : GTot Type0 = U32.v u < (match i with 1 -> 256 | 2 -> 65536 | 3 -> 16777216 | 4 -> 4294967296)
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 82, "end_line": 24, "start_col": 0, "start_line": 20 }
module LowParse.Spec.BoundedInt include LowParse.Spec.Base include LowParse.Spec.Int // for parse_u16_kind open FStar.Mul module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module E = FStar.Endianness (* bounded integers *) let integer_size : Type = (sz: nat { 1 <= sz /\ sz <= 4 } ) val integer_size_values (i: integer_size) : Lemma (i == 1 \/ i == 2 \/ i == 3 \/ i == 4)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BoundedInt.fsti" }
[ { "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 -> u6: FStar.UInt32.t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.int" ]
[]
false
false
false
false
true
let bounded_integer_prop (i: integer_size) (u: U32.t) : GTot Type0 =
U32.v u < (match i with | 1 -> 256 | 2 -> 65536 | 3 -> 16777216 | 4 -> 4294967296)
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_var
val tm_var (nm: nm) : term
val tm_var (nm: nm) : term
let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 29, "end_line": 52, "start_col": 0, "start_line": 50 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
nm: Pulse.Syntax.Base.nm -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.nm", "Pulse.Syntax.Base.tm_fstar", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_Var", "FStar.Stubs.Reflection.V2.Builtins.pack_namedv", "FStar.Reflection.Typing.make_namedv_with_name", "Pulse.Syntax.Base.__proj__Mkppname__item__name", "Pulse.Syntax.Base.__proj__Mknm__item__nm_ppname", "Pulse.Syntax.Base.__proj__Mknm__item__nm_index", "Pulse.Syntax.Base.__proj__Mkppname__item__range", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_var (nm: nm) : term =
tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range
false
LowParse.Spec.BoundedInt.fsti
LowParse.Spec.BoundedInt.parse_bounded_int32_kind
val parse_bounded_int32_kind (max: nat{0 < max /\ max < 4294967296}) : Tot parser_kind
val parse_bounded_int32_kind (max: nat{0 < max /\ max < 4294967296}) : Tot parser_kind
let parse_bounded_int32_kind (max: nat { 0 < max /\ max < 4294967296 }) : Tot parser_kind = [@inline_let] let sz = log256' max in { parser_kind_low = sz; parser_kind_high = Some sz; parser_kind_metadata = None; parser_kind_subkind = Some ParserStrong; }
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 194, "start_col": 0, "start_line": 184 }
module LowParse.Spec.BoundedInt include LowParse.Spec.Base include LowParse.Spec.Int // for parse_u16_kind open FStar.Mul module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module E = FStar.Endianness (* bounded integers *) let integer_size : Type = (sz: nat { 1 <= sz /\ sz <= 4 } ) val integer_size_values (i: integer_size) : Lemma (i == 1 \/ i == 2 \/ i == 3 \/ i == 4) let bounded_integer_prop (i: integer_size) (u: U32.t) : GTot Type0 = U32.v u < (match i with 1 -> 256 | 2 -> 65536 | 3 -> 16777216 | 4 -> 4294967296) val bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) inline_for_extraction let bounded_integer (i: integer_size) : Tot Type = (u: U32.t { bounded_integer_prop i u } ) inline_for_extraction let parse_bounded_integer_kind (i: integer_size) : Tot parser_kind = total_constant_size_parser_kind i val parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer 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 ) val serialize_bounded_integer (sz: integer_size) : Tot (serializer (parse_bounded_integer sz)) #push-options "--initial_fuel 8 --max_fuel 8 --initial_ifuel 0 --max_ifuel 0 --z3rlimit 20" val serialize_bounded_integer_spec (sz: integer_size) (x: bounded_integer sz) : Lemma (let (bx : nat {bx < pow2 (8 `FStar.Mul.op_Star` sz)}) = U32.v x in serialize (serialize_bounded_integer sz) x == E.n_to_be sz bx) val parse_bounded_integer_le (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) val parse_u16_le : parser parse_u16_kind U16.t val parse_u32_le : parser parse_u32_kind U32.t val serialize_bounded_integer_le (sz: integer_size) : Tot (serializer (parse_bounded_integer_le sz)) val serialize_u16_le : serializer parse_u16_le val serialize_u32_le : serializer parse_u32_le inline_for_extraction let log256' (n: nat) : Pure integer_size (requires (n > 0 /\ n < 4294967296)) (ensures (fun l -> pow2 (FStar.Mul.op_Star 8 (l - 1)) <= n /\ n < pow2 (FStar.Mul.op_Star 8 l) )) = [@inline_let] let _ = assert_norm (pow2 32 == 4294967296) in [@inline_let] let _ = assert (n < pow2 32) in [@inline_let] let z0 = 1 in [@inline_let] let z1 = 256 in [@inline_let] let _ = assert_norm (z1 == Prims.op_Multiply 256 z0) in [@inline_let] let l = 1 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z1) in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 (l - 1)) == z0) in if n < z1 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let z2 = 65536 in [@inline_let] let _ = assert_norm (z2 == Prims.op_Multiply 256 z1) in [@inline_let] let l = 2 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z2) in if n < z2 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let z3 = 16777216 in [@inline_let] let _ = assert_norm (z3 == Prims.op_Multiply 256 z2) in [@inline_let] let l = 3 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z3) in if n < z3 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let l = 4 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == Prims.op_Multiply 256 z3) in [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end end end let in_bounds (min: nat) (max: nat) (x: U32.t) : GTot bool = not (U32.v x < min || max < U32.v x) inline_for_extraction let bounded_int32 (min: nat) (max: nat { min <= max }) : Tot Type = (x: U32.t { in_bounds min max x } ) // unfold
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BoundedInt.fsti" }
[ { "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": 8, "initial_ifuel": 0, "max_fuel": 8, "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
max: Prims.nat{0 < max /\ max < 4294967296} -> LowParse.Spec.Base.parser_kind
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "LowParse.Spec.Base.Mkparser_kind'", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.ParserStrong", "FStar.Pervasives.Native.None", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser_kind" ]
[]
false
false
false
false
false
let parse_bounded_int32_kind (max: nat{0 < max /\ max < 4294967296}) : Tot parser_kind =
[@@ inline_let ]let sz = log256' max in { parser_kind_low = sz; parser_kind_high = Some sz; parser_kind_metadata = None; parser_kind_subkind = Some ParserStrong }
false
LowParse.Spec.BoundedInt.fsti
LowParse.Spec.BoundedInt.log256'
val log256' (n: nat) : Pure integer_size (requires (n > 0 /\ n < 4294967296)) (ensures (fun l -> pow2 (FStar.Mul.op_Star 8 (l - 1)) <= n /\ n < pow2 (FStar.Mul.op_Star 8 l)))
val log256' (n: nat) : Pure integer_size (requires (n > 0 /\ n < 4294967296)) (ensures (fun l -> pow2 (FStar.Mul.op_Star 8 (l - 1)) <= n /\ n < pow2 (FStar.Mul.op_Star 8 l)))
let log256' (n: nat) : Pure integer_size (requires (n > 0 /\ n < 4294967296)) (ensures (fun l -> pow2 (FStar.Mul.op_Star 8 (l - 1)) <= n /\ n < pow2 (FStar.Mul.op_Star 8 l) )) = [@inline_let] let _ = assert_norm (pow2 32 == 4294967296) in [@inline_let] let _ = assert (n < pow2 32) in [@inline_let] let z0 = 1 in [@inline_let] let z1 = 256 in [@inline_let] let _ = assert_norm (z1 == Prims.op_Multiply 256 z0) in [@inline_let] let l = 1 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z1) in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 (l - 1)) == z0) in if n < z1 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let z2 = 65536 in [@inline_let] let _ = assert_norm (z2 == Prims.op_Multiply 256 z1) in [@inline_let] let l = 2 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z2) in if n < z2 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let z3 = 16777216 in [@inline_let] let _ = assert_norm (z3 == Prims.op_Multiply 256 z2) in [@inline_let] let l = 3 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z3) in if n < z3 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let l = 4 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == Prims.op_Multiply 256 z3) in [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end end end
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 5, "end_line": 166, "start_col": 0, "start_line": 91 }
module LowParse.Spec.BoundedInt include LowParse.Spec.Base include LowParse.Spec.Int // for parse_u16_kind open FStar.Mul module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module E = FStar.Endianness (* bounded integers *) let integer_size : Type = (sz: nat { 1 <= sz /\ sz <= 4 } ) val integer_size_values (i: integer_size) : Lemma (i == 1 \/ i == 2 \/ i == 3 \/ i == 4) let bounded_integer_prop (i: integer_size) (u: U32.t) : GTot Type0 = U32.v u < (match i with 1 -> 256 | 2 -> 65536 | 3 -> 16777216 | 4 -> 4294967296) val bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) inline_for_extraction let bounded_integer (i: integer_size) : Tot Type = (u: U32.t { bounded_integer_prop i u } ) inline_for_extraction let parse_bounded_integer_kind (i: integer_size) : Tot parser_kind = total_constant_size_parser_kind i val parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer 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 ) val serialize_bounded_integer (sz: integer_size) : Tot (serializer (parse_bounded_integer sz)) #push-options "--initial_fuel 8 --max_fuel 8 --initial_ifuel 0 --max_ifuel 0 --z3rlimit 20" val serialize_bounded_integer_spec (sz: integer_size) (x: bounded_integer sz) : Lemma (let (bx : nat {bx < pow2 (8 `FStar.Mul.op_Star` sz)}) = U32.v x in serialize (serialize_bounded_integer sz) x == E.n_to_be sz bx) val parse_bounded_integer_le (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) val parse_u16_le : parser parse_u16_kind U16.t val parse_u32_le : parser parse_u32_kind U32.t val serialize_bounded_integer_le (sz: integer_size) : Tot (serializer (parse_bounded_integer_le sz)) val serialize_u16_le : serializer parse_u16_le val serialize_u32_le : serializer parse_u32_le
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BoundedInt.fsti" }
[ { "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": 8, "initial_ifuel": 0, "max_fuel": 8, "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> Prims.Pure LowParse.Spec.BoundedInt.integer_size
Prims.Pure
[]
[]
[ "Prims.nat", "Prims.op_LessThan", "Prims.unit", "Prims._assert", "Prims.b2t", "Prims.pow2", "Prims.op_Multiply", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.bool", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "LowParse.Spec.BoundedInt.integer_size", "Prims.l_and", "Prims.op_GreaterThan", "FStar.Mul.op_Star" ]
[]
false
false
false
false
false
let log256' (n: nat) : Pure integer_size (requires (n > 0 /\ n < 4294967296)) (ensures (fun l -> pow2 (FStar.Mul.op_Star 8 (l - 1)) <= n /\ n < pow2 (FStar.Mul.op_Star 8 l))) =
[@@ inline_let ]let _ = assert_norm (pow2 32 == 4294967296) in [@@ inline_let ]let _ = assert (n < pow2 32) in [@@ inline_let ]let z0 = 1 in [@@ inline_let ]let z1 = 256 in [@@ inline_let ]let _ = assert_norm (z1 == Prims.op_Multiply 256 z0) in [@@ inline_let ]let l = 1 in [@@ inline_let ]let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z1) in [@@ inline_let ]let _ = assert_norm (pow2 (Prims.op_Multiply 8 (l - 1)) == z0) in if n < z1 then [@@ inline_let ]let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@@ inline_let ]let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l else [@@ inline_let ]let z2 = 65536 in [@@ inline_let ]let _ = assert_norm (z2 == Prims.op_Multiply 256 z1) in [@@ inline_let ]let l = 2 in [@@ inline_let ]let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z2) in if n < z2 then [@@ inline_let ]let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@@ inline_let ]let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l else [@@ inline_let ]let z3 = 16777216 in [@@ inline_let ]let _ = assert_norm (z3 == Prims.op_Multiply 256 z2) in [@@ inline_let ]let l = 3 in [@@ inline_let ]let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z3) in if n < z3 then [@@ inline_let ]let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@@ inline_let ]let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l else [@@ inline_let ]let l = 4 in [@@ inline_let ]let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == Prims.op_Multiply 256 z3) in [@@ inline_let ]let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@@ inline_let ]let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l
false
LowParse.Spec.BoundedInt.fsti
LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind
val parse_bounded_int32_fixed_size_kind:parser_kind
val parse_bounded_int32_fixed_size_kind:parser_kind
let parse_bounded_int32_fixed_size_kind : parser_kind = { parser_kind_low = 4; parser_kind_high = Some 4; parser_kind_metadata = None; parser_kind_subkind = Some ParserStrong; }
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 225, "start_col": 0, "start_line": 218 }
module LowParse.Spec.BoundedInt include LowParse.Spec.Base include LowParse.Spec.Int // for parse_u16_kind open FStar.Mul module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module E = FStar.Endianness (* bounded integers *) let integer_size : Type = (sz: nat { 1 <= sz /\ sz <= 4 } ) val integer_size_values (i: integer_size) : Lemma (i == 1 \/ i == 2 \/ i == 3 \/ i == 4) let bounded_integer_prop (i: integer_size) (u: U32.t) : GTot Type0 = U32.v u < (match i with 1 -> 256 | 2 -> 65536 | 3 -> 16777216 | 4 -> 4294967296) val bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) inline_for_extraction let bounded_integer (i: integer_size) : Tot Type = (u: U32.t { bounded_integer_prop i u } ) inline_for_extraction let parse_bounded_integer_kind (i: integer_size) : Tot parser_kind = total_constant_size_parser_kind i val parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer 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 ) val serialize_bounded_integer (sz: integer_size) : Tot (serializer (parse_bounded_integer sz)) #push-options "--initial_fuel 8 --max_fuel 8 --initial_ifuel 0 --max_ifuel 0 --z3rlimit 20" val serialize_bounded_integer_spec (sz: integer_size) (x: bounded_integer sz) : Lemma (let (bx : nat {bx < pow2 (8 `FStar.Mul.op_Star` sz)}) = U32.v x in serialize (serialize_bounded_integer sz) x == E.n_to_be sz bx) val parse_bounded_integer_le (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) val parse_u16_le : parser parse_u16_kind U16.t val parse_u32_le : parser parse_u32_kind U32.t val serialize_bounded_integer_le (sz: integer_size) : Tot (serializer (parse_bounded_integer_le sz)) val serialize_u16_le : serializer parse_u16_le val serialize_u32_le : serializer parse_u32_le inline_for_extraction let log256' (n: nat) : Pure integer_size (requires (n > 0 /\ n < 4294967296)) (ensures (fun l -> pow2 (FStar.Mul.op_Star 8 (l - 1)) <= n /\ n < pow2 (FStar.Mul.op_Star 8 l) )) = [@inline_let] let _ = assert_norm (pow2 32 == 4294967296) in [@inline_let] let _ = assert (n < pow2 32) in [@inline_let] let z0 = 1 in [@inline_let] let z1 = 256 in [@inline_let] let _ = assert_norm (z1 == Prims.op_Multiply 256 z0) in [@inline_let] let l = 1 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z1) in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 (l - 1)) == z0) in if n < z1 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let z2 = 65536 in [@inline_let] let _ = assert_norm (z2 == Prims.op_Multiply 256 z1) in [@inline_let] let l = 2 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z2) in if n < z2 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let z3 = 16777216 in [@inline_let] let _ = assert_norm (z3 == Prims.op_Multiply 256 z2) in [@inline_let] let l = 3 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == z3) in if n < z3 then begin [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end else begin [@inline_let] let l = 4 in [@inline_let] let _ = assert_norm (pow2 (Prims.op_Multiply 8 l) == Prims.op_Multiply 256 z3) in [@inline_let] let _ = assert (pow2 (Prims.op_Multiply 8 (l - 1)) <= n) in [@inline_let] let _ = assert (n < pow2 (Prims.op_Multiply 8 l)) in l end end end let in_bounds (min: nat) (max: nat) (x: U32.t) : GTot bool = not (U32.v x < min || max < U32.v x) inline_for_extraction let bounded_int32 (min: nat) (max: nat { min <= max }) : Tot Type = (x: U32.t { in_bounds min max x } ) // unfold inline_for_extraction let parse_bounded_int32_kind (max: nat { 0 < max /\ max < 4294967296 }) : Tot parser_kind = [@inline_let] let sz = log256' max in { parser_kind_low = sz; parser_kind_high = Some sz; parser_kind_metadata = None; parser_kind_subkind = Some ParserStrong; } 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 serialize_bounded_int32 (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (serializer (parse_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)) val serialize_bounded_int32_le (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (serializer (parse_bounded_int32_le min max)) // unfold
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Int.fsti.checked", "LowParse.Spec.Base.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Endianness.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.BoundedInt.fsti" }
[ { "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": 8, "initial_ifuel": 0, "max_fuel": 8, "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
LowParse.Spec.Base.parser_kind
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.Mkparser_kind'", "FStar.Pervasives.Native.Some", "Prims.nat", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.ParserStrong", "FStar.Pervasives.Native.None", "LowParse.Spec.Base.parser_kind_metadata_some" ]
[]
false
false
false
true
false
let parse_bounded_int32_fixed_size_kind:parser_kind =
{ parser_kind_low = 4; parser_kind_high = Some 4; parser_kind_metadata = None; parser_kind_subkind = Some ParserStrong }
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_type
val tm_type (u: universe) : term
val tm_type (u: universe) : term
let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 104, "start_col": 0, "start_line": 103 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
u61: Pulse.Syntax.Base.universe -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.tm_fstar", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_Type", "FStar.Range.range_0", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_type (u: universe) : term =
tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_constant
val tm_constant (c: constant) : term
val tm_constant (c: constant) : term
let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 57, "end_line": 63, "start_col": 0, "start_line": 62 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
c: Pulse.Syntax.Base.constant -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.constant", "Pulse.Syntax.Base.tm_fstar", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_Const", "FStar.Range.range_0", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_constant (c: constant) : term =
tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_let
val tm_let (t e1 e2: term) : term
val tm_let (t e1 e2: term) : term
let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 77, "start_col": 0, "start_line": 70 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> e1: Pulse.Syntax.Base.term -> e2: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.tm_fstar", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_Let", "Prims.Nil", "FStar.Stubs.Reflection.Types.term", "Pulse.Elaborate.Pure.elab_term", "FStar.Range.range_0", "FStar.Stubs.Reflection.V2.Data.simple_binder", "FStar.Reflection.Typing.mk_simple_binder", "FStar.Reflection.Typing.pp_name_default" ]
[]
false
false
false
true
false
let tm_let (t e1 e2: term) : term =
let rb:R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_refine
val tm_refine (b: binder) (t: term) : term
val tm_refine (b: binder) (t: term) : term
let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 68, "start_col": 0, "start_line": 65 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
b: Pulse.Syntax.Base.binder -> t: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.binder", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.tm_fstar", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_Refine", "Pulse.Elaborate.Pure.elab_term", "FStar.Range.range_0", "FStar.Stubs.Reflection.V2.Data.simple_binder", "FStar.Reflection.Typing.mk_simple_binder", "Pulse.Syntax.Base.__proj__Mkppname__item__name", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty" ]
[]
false
false
false
true
false
let tm_refine (b: binder) (t: term) : term =
let rb:R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_uinst
val tm_uinst (l: fv) (us: list universe) : term
val tm_uinst (l: fv) (us: list universe) : term
let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 21, "end_line": 60, "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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.fv -> us: Prims.list Pulse.Syntax.Base.universe -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.fv", "Prims.list", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.tm_fstar", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_UInst", "FStar.Stubs.Reflection.V2.Builtins.pack_fv", "Pulse.Syntax.Base.__proj__Mkfv__item__fv_name", "Pulse.Syntax.Base.__proj__Mkfv__item__fv_range", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_uinst (l: fv) (us: list universe) : term =
tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.is_eq2
val is_eq2 (t: term) : option (term & term & term)
val is_eq2 (t: term) : option (term & term & term)
let is_eq2 (t:term) : option (term & term & term) = match is_pure_app t with | Some (head, None, a2) -> (match is_pure_app head with | Some (head, None, a1) -> (match is_pure_app head with | Some (head, Some Implicit, ty) -> (match is_fvar head with | Some (l, _) -> if l = ["Pulse"; "Steel"; "Wrapper"; "eq2_prop"] || l = ["Prims"; "eq2"] then Some (ty, a1, a2) else None | _ -> None) | _ -> None) | _ -> None) | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 256, "start_col": 0, "start_line": 240 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x} let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x) let is_bvar (t:term) : option nat = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None end | _ -> None let is_var (t:term) : option nm = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_Var nv -> let nv_view = R.inspect_namedv nv in Some {nm_index=nv_view.uniq; nm_ppname=mk_ppname (nv_view.ppname) t.range} | _ -> None end | _ -> None let is_fvar (t:term) : option (R.name & list universe) = let open R in match t.t with | Tm_FStar host_term -> begin match inspect_ln host_term with | Tv_FVar fv -> Some (inspect_fv fv, []) | Tv_UInst fv us -> Some (inspect_fv fv, us) | _ -> None end | _ -> None let is_pure_app (t:term) : option (term & option qualifier & term) = match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_App hd (arg, q) -> let? hd = match readback_ty hd with | Some hd -> Some hd <: option term | _ -> None in let q = readback_qual q in let? arg = match readback_ty arg with | Some arg -> Some arg <: option term | _ -> None in Some (hd, q, arg) | _ -> None end | _ -> None let leftmost_head (t:term) : option term = match t.t with | Tm_FStar host_term -> let hd, _ = R.collect_app_ln host_term in (match readback_ty hd with | Some t -> Some t | None -> None) | _ -> None let is_fvar_app (t:term) : option (R.name & list universe & option qualifier & option term) = match is_fvar t with | Some (l, us) -> Some (l, us, None, None) | None -> match is_pure_app t with | Some (head, q, arg) -> (match is_fvar head with | Some (l, us) -> Some (l, us, q, Some arg) | None -> None) | _ -> None let is_arrow (t:term) : option (binder & option qualifier & comp) = match t.t with | Tm_FStar host_term -> begin match R.inspect_ln_unascribe host_term with | R.Tv_Arrow b c -> let {ppname;qual;sort} = R.inspect_binder b in begin match qual with | R.Q_Meta _ -> None | _ -> let q = readback_qual qual in let c_view = R.inspect_comp c in let ret (c_t:R.typ) = let? binder_ty = readback_ty sort in let? c = match readback_comp c_t with | Some c -> Some c <: option Pulse.Syntax.Base.comp | None -> None in Some (mk_binder_ppname binder_ty (mk_ppname ppname (T.range_of_term host_term)), q, c) in begin match c_view with | R.C_Total c_t -> ret c_t | R.C_Eff _ eff_name c_t _ _ -> // // Consider Tot effect with decreases also // if eff_name = tot_lid then ret c_t else None | _ -> None end end | _ -> None end | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option ((Pulse.Syntax.Base.term * Pulse.Syntax.Base.term) * Pulse.Syntax.Base.term)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Pure.is_pure_app", "Pulse.Syntax.Pure.is_fvar", "FStar.Stubs.Reflection.Types.name", "Prims.list", "Pulse.Syntax.Base.universe", "Prims.op_BarBar", "Prims.op_Equality", "Prims.string", "Prims.Cons", "Prims.Nil", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.Mktuple3", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.qualifier" ]
[]
false
false
false
true
false
let is_eq2 (t: term) : option (term & term & term) =
match is_pure_app t with | Some (head, None, a2) -> (match is_pure_app head with | Some (head, None, a1) -> (match is_pure_app head with | Some (head, Some Implicit, ty) -> (match is_fvar head with | Some (l, _) -> if l = ["Pulse"; "Steel"; "Wrapper"; "eq2_prop"] || l = ["Prims"; "eq2"] then Some (ty, a1, a2) else None | _ -> None) | _ -> None) | _ -> None) | _ -> None
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_fvar
val tm_fvar (l: fv) : term
val tm_fvar (l: fv) : term
let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 21, "end_line": 56, "start_col": 0, "start_line": 54 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.fv -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.fv", "Pulse.Syntax.Base.tm_fstar", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_FVar", "FStar.Stubs.Reflection.V2.Builtins.pack_fv", "Pulse.Syntax.Base.__proj__Mkfv__item__fv_name", "Pulse.Syntax.Base.__proj__Mkfv__item__fv_range", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_fvar (l: fv) : term =
tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.is_fvar_app
val is_fvar_app (t: term) : option (R.name & list universe & option qualifier & option term)
val is_fvar_app (t: term) : option (R.name & list universe & option qualifier & option term)
let is_fvar_app (t:term) : option (R.name & list universe & option qualifier & option term) = match is_fvar t with | Some (l, us) -> Some (l, us, None, None) | None -> match is_pure_app t with | Some (head, q, arg) -> (match is_fvar head with | Some (l, us) -> Some (l, us, q, Some arg) | None -> None) | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 15, "end_line": 197, "start_col": 0, "start_line": 185 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x} let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x) let is_bvar (t:term) : option nat = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None end | _ -> None let is_var (t:term) : option nm = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_Var nv -> let nv_view = R.inspect_namedv nv in Some {nm_index=nv_view.uniq; nm_ppname=mk_ppname (nv_view.ppname) t.range} | _ -> None end | _ -> None let is_fvar (t:term) : option (R.name & list universe) = let open R in match t.t with | Tm_FStar host_term -> begin match inspect_ln host_term with | Tv_FVar fv -> Some (inspect_fv fv, []) | Tv_UInst fv us -> Some (inspect_fv fv, us) | _ -> None end | _ -> None let is_pure_app (t:term) : option (term & option qualifier & term) = match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_App hd (arg, q) -> let? hd = match readback_ty hd with | Some hd -> Some hd <: option term | _ -> None in let q = readback_qual q in let? arg = match readback_ty arg with | Some arg -> Some arg <: option term | _ -> None in Some (hd, q, arg) | _ -> None end | _ -> None let leftmost_head (t:term) : option term = match t.t with | Tm_FStar host_term -> let hd, _ = R.collect_app_ln host_term in (match readback_ty hd with | Some t -> Some t | None -> None) | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option (((FStar.Stubs.Reflection.Types.name * Prims.list Pulse.Syntax.Base.universe) * FStar.Pervasives.Native.option Pulse.Syntax.Base.qualifier) * FStar.Pervasives.Native.option Pulse.Syntax.Base.term)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Pure.is_fvar", "FStar.Stubs.Reflection.Types.name", "Prims.list", "Pulse.Syntax.Base.universe", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple4", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.qualifier", "FStar.Pervasives.Native.Mktuple4", "FStar.Pervasives.Native.None", "Pulse.Syntax.Pure.is_pure_app", "FStar.Pervasives.Native.tuple3" ]
[]
false
false
false
true
false
let is_fvar_app (t: term) : option (R.name & list universe & option qualifier & option term) =
match is_fvar t with | Some (l, us) -> Some (l, us, None, None) | None -> match is_pure_app t with | Some (head, q, arg) -> (match is_fvar head with | Some (l, us) -> Some (l, us, q, Some arg) | None -> None) | _ -> None
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_arrow
val tm_arrow (b: binder) (q: option qualifier) (c: comp) : term
val tm_arrow (b: binder) (q: option qualifier) (c: comp) : term
let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 101, "start_col": 0, "start_line": 98 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
b: Pulse.Syntax.Base.binder -> q: FStar.Pervasives.Native.option Pulse.Syntax.Base.qualifier -> c: Pulse.Syntax.Base.comp -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.binder", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.qualifier", "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.tm_fstar", "Pulse.Reflection.Util.mk_arrow_with_name", "Pulse.Syntax.Base.__proj__Mkppname__item__name", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Elaborate.Pure.elab_term", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Elaborate.Pure.elab_qual", "Pulse.Elaborate.Pure.elab_comp", "FStar.Range.range_0", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_arrow (b: binder) (q: option qualifier) (c: comp) : term =
tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c) ) FStar.Range.range_0
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_bvar
val tm_bvar (bv: bv) : term
val tm_bvar (bv: bv) : term
let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 48, "start_col": 0, "start_line": 46 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
bv: Pulse.Syntax.Base.bv -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.bv", "Pulse.Syntax.Base.tm_fstar", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_BVar", "FStar.Stubs.Reflection.V2.Builtins.pack_bv", "FStar.Reflection.Typing.make_bv_with_name", "Pulse.Syntax.Base.__proj__Mkppname__item__name", "Pulse.Syntax.Base.__proj__Mkbv__item__bv_ppname", "Pulse.Syntax.Base.__proj__Mkbv__item__bv_index", "Pulse.Syntax.Base.__proj__Mkppname__item__range", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_bvar (bv: bv) : term =
tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.leftmost_head
val leftmost_head (t: term) : option term
val leftmost_head (t: term) : option term
let leftmost_head (t:term) : option term = match t.t with | Tm_FStar host_term -> let hd, _ = R.collect_app_ln host_term in (match readback_ty hd with | Some t -> Some t | None -> None) | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 183, "start_col": 0, "start_line": 176 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x} let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x) let is_bvar (t:term) : option nat = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None end | _ -> None let is_var (t:term) : option nm = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_Var nv -> let nv_view = R.inspect_namedv nv in Some {nm_index=nv_view.uniq; nm_ppname=mk_ppname (nv_view.ppname) t.range} | _ -> None end | _ -> None let is_fvar (t:term) : option (R.name & list universe) = let open R in match t.t with | Tm_FStar host_term -> begin match inspect_ln host_term with | Tv_FVar fv -> Some (inspect_fv fv, []) | Tv_UInst fv us -> Some (inspect_fv fv, us) | _ -> None end | _ -> None let is_pure_app (t:term) : option (term & option qualifier & term) = match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_App hd (arg, q) -> let? hd = match readback_ty hd with | Some hd -> Some hd <: option term | _ -> None in let q = readback_qual q in let? arg = match readback_ty arg with | Some arg -> Some arg <: option term | _ -> None in Some (hd, q, arg) | _ -> None end | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "Pulse.Readback.readback_ty", "Prims.eq2", "Pulse.Elaborate.Pure.elab_term", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Derived.collect_app_ln", "Pulse.Syntax.Base.term'" ]
[]
false
false
false
true
false
let leftmost_head (t: term) : option term =
match t.t with | Tm_FStar host_term -> let hd, _ = R.collect_app_ln host_term in (match readback_ty hd with | Some t -> Some t | None -> None) | _ -> None
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.is_var
val is_var (t: term) : option nm
val is_var (t: term) : option nm
let is_var (t:term) : option nm = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_Var nv -> let nv_view = R.inspect_namedv nv in Some {nm_index=nv_view.uniq; nm_ppname=mk_ppname (nv_view.ppname) t.range} | _ -> None end | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 143, "start_col": 0, "start_line": 132 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x} let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x) let is_bvar (t:term) : option nat = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None end | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option Pulse.Syntax.Base.nm
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.namedv", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.nm", "Pulse.Syntax.Base.Mknm", "FStar.Stubs.Reflection.V2.Data.__proj__Mknamedv_view__item__uniq", "Pulse.Syntax.Base.mk_ppname", "FStar.Stubs.Reflection.V2.Data.__proj__Mknamedv_view__item__ppname", "Pulse.Syntax.Base.__proj__Mkterm__item__range", "FStar.Stubs.Reflection.V2.Data.namedv_view", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_namedv", "FStar.Stubs.Reflection.V2.Data.term_view", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.term'" ]
[]
false
false
false
true
false
let is_var (t: term) : option nm =
let open R in match t.t with | Tm_FStar host_term -> (match R.inspect_ln host_term with | R.Tv_Var nv -> let nv_view = R.inspect_namedv nv in Some ({ nm_index = nv_view.uniq; nm_ppname = mk_ppname (nv_view.ppname) t.range }) | _ -> None) | _ -> None
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.is_arrow
val is_arrow (t: term) : option (binder & option qualifier & comp)
val is_arrow (t: term) : option (binder & option qualifier & comp)
let is_arrow (t:term) : option (binder & option qualifier & comp) = match t.t with | Tm_FStar host_term -> begin match R.inspect_ln_unascribe host_term with | R.Tv_Arrow b c -> let {ppname;qual;sort} = R.inspect_binder b in begin match qual with | R.Q_Meta _ -> None | _ -> let q = readback_qual qual in let c_view = R.inspect_comp c in let ret (c_t:R.typ) = let? binder_ty = readback_ty sort in let? c = match readback_comp c_t with | Some c -> Some c <: option Pulse.Syntax.Base.comp | None -> None in Some (mk_binder_ppname binder_ty (mk_ppname ppname (T.range_of_term host_term)), q, c) in begin match c_view with | R.C_Total c_t -> ret c_t | R.C_Eff _ eff_name c_t _ _ -> // // Consider Tot effect with decreases also // if eff_name = tot_lid then ret c_t else None | _ -> None end end | _ -> None end | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 237, "start_col": 0, "start_line": 199 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x} let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x) let is_bvar (t:term) : option nat = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None end | _ -> None let is_var (t:term) : option nm = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_Var nv -> let nv_view = R.inspect_namedv nv in Some {nm_index=nv_view.uniq; nm_ppname=mk_ppname (nv_view.ppname) t.range} | _ -> None end | _ -> None let is_fvar (t:term) : option (R.name & list universe) = let open R in match t.t with | Tm_FStar host_term -> begin match inspect_ln host_term with | Tv_FVar fv -> Some (inspect_fv fv, []) | Tv_UInst fv us -> Some (inspect_fv fv, us) | _ -> None end | _ -> None let is_pure_app (t:term) : option (term & option qualifier & term) = match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_App hd (arg, q) -> let? hd = match readback_ty hd with | Some hd -> Some hd <: option term | _ -> None in let q = readback_qual q in let? arg = match readback_ty arg with | Some arg -> Some arg <: option term | _ -> None in Some (hd, q, arg) | _ -> None end | _ -> None let leftmost_head (t:term) : option term = match t.t with | Tm_FStar host_term -> let hd, _ = R.collect_app_ln host_term in (match readback_ty hd with | Some t -> Some t | None -> None) | _ -> None let is_fvar_app (t:term) : option (R.name & list universe & option qualifier & option term) = match is_fvar t with | Some (l, us) -> Some (l, us, None, None) | None -> match is_pure_app t with | Some (head, q, arg) -> (match is_fvar head with | Some (l, us) -> Some (l, us, q, Some arg) | None -> None) | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option ((Pulse.Syntax.Base.binder * FStar.Pervasives.Native.option Pulse.Syntax.Base.qualifier) * Pulse.Syntax.Base.comp)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "FStar.Reflection.V2.Derived.inspect_ln_unascribe", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.V2.Data.aqualv", "Prims.list", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.ppname_t", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple3", "Pulse.Syntax.Base.binder", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.qualifier", "Pulse.Syntax.Base.comp", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Stubs.Reflection.Types.name", "FStar.Stubs.Reflection.V2.Data.argv", "Prims.op_Equality", "Prims.string", "Pulse.Reflection.Util.tot_lid", "Prims.bool", "FStar.Stubs.Reflection.V2.Data.comp_view", "Pulse.Syntax.Pure.op_let_Question", "Prims.eq2", "Pulse.Elaborate.Pure.elab_term", "Pulse.Readback.readback_ty", "Pulse.Readback.readback_comp", "Pulse.Elaborate.Pure.elab_comp", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple3", "Pulse.Syntax.Base.mk_binder_ppname", "Pulse.Syntax.Base.mk_ppname", "FStar.Stubs.Reflection.V2.Builtins.range_of_term", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_comp", "Pulse.Readback.readback_qual", "FStar.Stubs.Reflection.V2.Data.binder_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_binder", "FStar.Stubs.Reflection.V2.Data.term_view", "Pulse.Syntax.Base.term'" ]
[]
false
false
false
true
false
let is_arrow (t: term) : option (binder & option qualifier & comp) =
match t.t with | Tm_FStar host_term -> (match R.inspect_ln_unascribe host_term with | R.Tv_Arrow b c -> let { ppname = ppname ; qual = qual ; sort = sort } = R.inspect_binder b in (match qual with | R.Q_Meta _ -> None | _ -> let q = readback_qual qual in let c_view = R.inspect_comp c in let ret (c_t: R.typ) = let? binder_ty = readback_ty sort in let? c = match readback_comp c_t with | Some c -> Some c <: option Pulse.Syntax.Base.comp | None -> None in Some (mk_binder_ppname binder_ty (mk_ppname ppname (T.range_of_term host_term)), q, c) in match c_view with | R.C_Total c_t -> ret c_t | R.C_Eff _ eff_name c_t _ _ -> if eff_name = tot_lid then ret c_t else None | _ -> None) | _ -> None) | _ -> None
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.unreveal
val unreveal (t: term) : option term
val unreveal (t: term) : option term
let unreveal (t:term) : option term = match is_pure_app t with | Some (head, None, arg) -> (match is_pure_app head with | Some (head, Some Implicit, _) -> (match is_fvar head with | Some (l, _) -> if l = ["FStar"; "Ghost"; "reveal"] then Some arg else None | _ -> None) | _ -> None) | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 270, "start_col": 0, "start_line": 258 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0 let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0 let tm_pureabs (ppname:R.ppname_t) (ty : term) (q : option qualifier) (body:term) : term = let open R in let open T in let b : T.binder = { uniq = 0; ppname = ppname; sort = elab_term ty; qual = elab_qual q; attrs = []; } in let r = pack (Tv_Abs b (elab_term body)) in assume (~(R.Tv_Unknown? (R.inspect_ln r))); // NamedView API doesn't ensure this, it should tm_fstar r FStar.Range.range_0 let tm_arrow (b:binder) (q:option qualifier) (c:comp) : term = tm_fstar (mk_arrow_with_name b.binder_ppname.name (elab_term b.binder_ty, elab_qual q) (elab_comp c)) FStar.Range.range_0 let tm_type (u:universe) : term = tm_fstar (R.pack_ln (R.Tv_Type u)) FStar.Range.range_0 let mk_bvar (s:string) (r:Range.range) (i:index) : term = tm_bvar {bv_index=i;bv_ppname=mk_ppname (RT.seal_pp_name s) r} let null_var (v:var) : term = tm_var {nm_index=v;nm_ppname=ppname_default} let null_bvar (i:index) : term = tm_bvar {bv_index=i;bv_ppname=ppname_default} let term_of_nvar (x:nvar) : term = tm_var { nm_index=snd x; nm_ppname=fst x} let term_of_no_name_var (x:var) : term = term_of_nvar (v_as_nv x) let is_bvar (t:term) : option nat = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_BVar bv -> let bv_view = R.inspect_bv bv in Some bv_view.index | _ -> None end | _ -> None let is_var (t:term) : option nm = let open R in match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_Var nv -> let nv_view = R.inspect_namedv nv in Some {nm_index=nv_view.uniq; nm_ppname=mk_ppname (nv_view.ppname) t.range} | _ -> None end | _ -> None let is_fvar (t:term) : option (R.name & list universe) = let open R in match t.t with | Tm_FStar host_term -> begin match inspect_ln host_term with | Tv_FVar fv -> Some (inspect_fv fv, []) | Tv_UInst fv us -> Some (inspect_fv fv, us) | _ -> None end | _ -> None let is_pure_app (t:term) : option (term & option qualifier & term) = match t.t with | Tm_FStar host_term -> begin match R.inspect_ln host_term with | R.Tv_App hd (arg, q) -> let? hd = match readback_ty hd with | Some hd -> Some hd <: option term | _ -> None in let q = readback_qual q in let? arg = match readback_ty arg with | Some arg -> Some arg <: option term | _ -> None in Some (hd, q, arg) | _ -> None end | _ -> None let leftmost_head (t:term) : option term = match t.t with | Tm_FStar host_term -> let hd, _ = R.collect_app_ln host_term in (match readback_ty hd with | Some t -> Some t | None -> None) | _ -> None let is_fvar_app (t:term) : option (R.name & list universe & option qualifier & option term) = match is_fvar t with | Some (l, us) -> Some (l, us, None, None) | None -> match is_pure_app t with | Some (head, q, arg) -> (match is_fvar head with | Some (l, us) -> Some (l, us, q, Some arg) | None -> None) | _ -> None let is_arrow (t:term) : option (binder & option qualifier & comp) = match t.t with | Tm_FStar host_term -> begin match R.inspect_ln_unascribe host_term with | R.Tv_Arrow b c -> let {ppname;qual;sort} = R.inspect_binder b in begin match qual with | R.Q_Meta _ -> None | _ -> let q = readback_qual qual in let c_view = R.inspect_comp c in let ret (c_t:R.typ) = let? binder_ty = readback_ty sort in let? c = match readback_comp c_t with | Some c -> Some c <: option Pulse.Syntax.Base.comp | None -> None in Some (mk_binder_ppname binder_ty (mk_ppname ppname (T.range_of_term host_term)), q, c) in begin match c_view with | R.C_Total c_t -> ret c_t | R.C_Eff _ eff_name c_t _ _ -> // // Consider Tot effect with decreases also // if eff_name = tot_lid then ret c_t else None | _ -> None end end | _ -> None end | _ -> None // TODO: write it better, with pattern matching on reflection syntax let is_eq2 (t:term) : option (term & term & term) = match is_pure_app t with | Some (head, None, a2) -> (match is_pure_app head with | Some (head, None, a1) -> (match is_pure_app head with | Some (head, Some Implicit, ty) -> (match is_fvar head with | Some (l, _) -> if l = ["Pulse"; "Steel"; "Wrapper"; "eq2_prop"] || l = ["Prims"; "eq2"] then Some (ty, a1, a2) else None | _ -> None) | _ -> None) | _ -> None) | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
t: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Pure.is_pure_app", "Pulse.Syntax.Pure.is_fvar", "FStar.Stubs.Reflection.Types.name", "Prims.list", "Pulse.Syntax.Base.universe", "Prims.op_Equality", "Prims.string", "Prims.Cons", "Prims.Nil", "FStar.Pervasives.Native.Some", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Pulse.Syntax.Base.qualifier" ]
[]
false
false
false
true
false
let unreveal (t: term) : option term =
match is_pure_app t with | Some (head, None, arg) -> (match is_pure_app head with | Some (head, Some Implicit, _) -> (match is_fvar head with | Some (l, _) -> if l = ["FStar"; "Ghost"; "reveal"] then Some arg else None | _ -> None) | _ -> None) | _ -> None
false
Pulse.Syntax.Pure.fst
Pulse.Syntax.Pure.tm_pureapp
val tm_pureapp (head: term) (q: option qualifier) (arg: term) : term
val tm_pureapp (head: term) (q: option qualifier) (arg: term) : term
let tm_pureapp (head:term) (q:option qualifier) (arg:term) : term = tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Pure.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 81, "start_col": 0, "start_line": 79 }
(* 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.Syntax.Pure module R = FStar.Reflection.V2 module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing open Pulse.Syntax.Base open Pulse.Elaborate.Pure open Pulse.Readback open Pulse.Reflection.Util let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let u0 : universe = R.pack_universe R.Uv_Zero let u1 : universe = R.pack_universe (R.Uv_Succ u0) let u2 : universe = R.pack_universe (R.Uv_Succ u1) let u_zero = u0 let u_succ (u:universe) : universe = R.pack_universe (R.Uv_Succ u) let u_var (s:string) : universe = R.pack_universe (R.Uv_Name (R.pack_ident (s, FStar.Range.range_0))) let u_max (u0 u1:universe) : universe = R.pack_universe (R.Uv_Max [u0; u1]) let u_unknown : universe = R.pack_universe R.Uv_Unk let tm_bvar (bv:bv) : term = tm_fstar (R.pack_ln (R.Tv_BVar (R.pack_bv (RT.make_bv_with_name bv.bv_ppname.name bv.bv_index)))) bv.bv_ppname.range let tm_var (nm:nm) : term = tm_fstar (R.pack_ln (R.Tv_Var (R.pack_namedv (RT.make_namedv_with_name nm.nm_ppname.name nm.nm_index)))) nm.nm_ppname.range let tm_fvar (l:fv) : term = tm_fstar (R.pack_ln (R.Tv_FVar (R.pack_fv l.fv_name))) l.fv_range let tm_uinst (l:fv) (us:list universe) : term = tm_fstar (R.pack_ln (R.Tv_UInst (R.pack_fv l.fv_name) us)) l.fv_range let tm_constant (c:constant) : term = tm_fstar (R.pack_ln (R.Tv_Const c)) FStar.Range.range_0 let tm_refine (b:binder) (t:term) : term = let rb : R.simple_binder = RT.mk_simple_binder b.binder_ppname.name (elab_term b.binder_ty) in tm_fstar (R.pack_ln (R.Tv_Refine rb (elab_term t))) FStar.Range.range_0 let tm_let (t e1 e2:term) : term = let rb : R.simple_binder = RT.mk_simple_binder RT.pp_name_default (elab_term t) in tm_fstar (R.pack_ln (R.Tv_Let false [] rb (elab_term e1) (elab_term e2))) FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Base.fsti.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Readback.fsti.checked", "Pulse.Elaborate.Pure.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Pure.fst" }
[ { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Readback", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": 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
head: Pulse.Syntax.Base.term -> q: FStar.Pervasives.Native.option Pulse.Syntax.Base.qualifier -> arg: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.qualifier", "Pulse.Syntax.Base.tm_fstar", "FStar.Reflection.V2.Derived.mk_app", "Pulse.Elaborate.Pure.elab_term", "Prims.Cons", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Elaborate.Pure.elab_qual", "Prims.Nil", "FStar.Range.range_0" ]
[]
false
false
false
true
false
let tm_pureapp (head: term) (q: option qualifier) (arg: term) : term =
tm_fstar (R.mk_app (elab_term head) [(elab_term arg, elab_qual q)]) FStar.Range.range_0
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake
val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n
val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n
let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 54, "end_line": 62, "start_col": 0, "start_line": 60 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> Spec.Matrix.matrix n n
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Lib.LoopCombinators.repeati", "Spec.Matrix.matrix", "Spec.Frodo.Gen.frodo_gen_matrix_shake1", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Spec.Matrix.create" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake n seed =
let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake1
val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n
val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n
let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 52, "start_col": 0, "start_line": 50 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> i: Lib.IntTypes.size_nat{i < n} -> res: Spec.Matrix.matrix n n -> Spec.Matrix.matrix n n
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Prims.op_LessThan", "Spec.Matrix.matrix", "Lib.LoopCombinators.repeati", "Spec.Frodo.Gen.frodo_gen_matrix_shake0", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Spec.Frodo.Gen.frodo_gen_matrix_shake_get_r" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake1 n seed i res =
let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake_fc
val frodo_gen_matrix_shake_fc: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> j:size_nat{j < n} -> GTot uint16
val frodo_gen_matrix_shake_fc: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> j:size_nat{j < n} -> GTot uint16
let frodo_gen_matrix_shake_fc n seed i j = let res_i = frodo_gen_matrix_shake_get_r n seed i in uint_from_bytes_le (LSeq.sub res_i (j * 2) 2)
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 168, "start_col": 0, "start_line": 166 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3 val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x1 n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake_4x n seed = let res = Matrix.create n n in let n4 = n / 4 in Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res val frodo_gen_matrix_aes: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_aes n seed = let res = Matrix.create n n in let key = aes128_key_expansion seed in let tmp = LSeq.create 8 (u16 0) in let n1 = n / 8 in Loops.repeati n (fun i res -> Loops.repeati n1 (fun j res -> let j = j * 8 in let tmp = tmp.[0] <- u16 i in let tmp = tmp.[1] <- u16 j in let res_i = aes_encrypt_block AES128 key (uints_to_bytes_le tmp) in Loops.repeati 8 (fun k res -> res.(i, j + k) <- uint_from_bytes_le (LSeq.sub res_i (k * 2) 2) ) res ) res ) res (** Lemma (frodo_gen_matrix_shake == frodo_gen_matrix_shake_4x) *) val frodo_gen_matrix_shake_fc: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> j:size_nat{j < n} -> GTot uint16
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> i: Lib.IntTypes.size_nat{i < n} -> j: Lib.IntTypes.size_nat{j < n} -> Prims.GTot Lib.IntTypes.uint16
Prims.GTot
[ "sometrivial" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Prims.op_LessThan", "Lib.ByteSequence.uint_from_bytes_le", "Lib.IntTypes.SEC", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Prims.op_Multiply", "Spec.Frodo.Gen.frodo_gen_matrix_shake_get_r", "Lib.IntTypes.uint16" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake_fc n seed i j =
let res_i = frodo_gen_matrix_shake_get_r n seed i in uint_from_bytes_le (LSeq.sub res_i (j * 2) 2)
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake_4x
val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n
val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n
let frodo_gen_matrix_shake_4x n seed = let res = Matrix.create n n in let n4 = n / 4 in Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 128, "start_col": 0, "start_line": 125 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3 val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x1 n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16 /\ n % 4 = 0} -> seed: Lib.ByteSequence.lbytes 16 -> Spec.Matrix.matrix n n
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "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.ByteSequence.lbytes", "Lib.LoopCombinators.repeati", "Spec.Matrix.matrix", "Spec.Frodo.Gen.frodo_gen_matrix_shake_4x1", "Prims.op_Division", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Spec.Matrix.create" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake_4x n seed =
let res = Matrix.create n n in let n4 = n / 4 in Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake0
val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n
val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n
let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2)
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 40, "start_col": 0, "start_line": 39 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat{n * n <= Lib.IntTypes.max_size_t} -> i: Lib.IntTypes.size_nat{i < n} -> res_i: Lib.ByteSequence.lbytes (2 * n) -> j: Lib.IntTypes.size_nat{j < n} -> res0: Spec.Matrix.matrix n n -> Spec.Matrix.matrix n n
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.op_LessThan", "Lib.ByteSequence.lbytes", "Spec.Matrix.matrix", "Spec.Matrix.op_Array_Assignment", "FStar.Pervasives.Native.Mktuple2", "Lib.ByteSequence.uint_from_bytes_le", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake0 n i res_i j res0 =
res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2)
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake_4x1
val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n
val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n
let frodo_gen_matrix_shake_4x1 n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 66, "end_line": 117, "start_col": 0, "start_line": 115 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3 val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> i: Lib.IntTypes.size_nat{i < n / 4} -> res: Spec.Matrix.matrix n n -> Spec.Matrix.matrix n n
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Prims.op_LessThan", "Prims.op_Division", "Spec.Matrix.matrix", "Lib.LoopCombinators.repeati", "Spec.Frodo.Gen.frodo_gen_matrix_shake_4x0", "FStar.Pervasives.Native.tuple4", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Spec.Frodo.Gen.frodo_gen_matrix_shake_4x1_get_r" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake_4x1 n seed i res =
let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake_4x0
val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n
val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n
let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 81, "start_col": 0, "start_line": 76 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> i: Lib.IntTypes.size_nat{i < n / 4} -> r0: Lib.ByteSequence.lbytes (2 * n) -> r1: Lib.ByteSequence.lbytes (2 * n) -> r2: Lib.ByteSequence.lbytes (2 * n) -> r3: Lib.ByteSequence.lbytes (2 * n) -> j: Lib.IntTypes.size_nat{j < n} -> res0: Spec.Matrix.matrix n n -> Spec.Matrix.matrix n n
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Prims.op_LessThan", "Prims.op_Division", "Lib.ByteSequence.lbytes", "Spec.Matrix.matrix", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Spec.Matrix.op_Array_Assignment", "FStar.Pervasives.Native.Mktuple2", "Prims.op_Addition", "Lib.ByteSequence.uint_from_bytes_le", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 =
let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake_4x1_get_r
val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n)
val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n)
let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 105, "start_col": 0, "start_line": 90 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n)
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> i: Lib.IntTypes.size_nat{i < n / 4} -> ((Lib.ByteSequence.lbytes (2 * n) * Lib.ByteSequence.lbytes (2 * n)) * Lib.ByteSequence.lbytes (2 * n)) * Lib.ByteSequence.lbytes (2 * n)
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Prims.op_LessThan", "Prims.op_Division", "FStar.Pervasives.Native.Mktuple4", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Spec.SHA3.shake128", "Prims.op_Addition", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.append", "Lib.Sequence.concat", "Lib.IntTypes.uint_t", "Lib.IntTypes.numbytes", "Lib.ByteSequence.uint_to_bytes_le", "Lib.IntTypes.u16", "FStar.Pervasives.Native.tuple4" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake_4x1_get_r n seed i =
let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake_get_r
val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n)
val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n)
let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n)
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 28, "start_col": 0, "start_line": 25 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n)
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> i: Lib.IntTypes.size_nat{i < n} -> Lib.ByteSequence.lbytes (2 * n)
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Prims.op_LessThan", "Spec.SHA3.shake128", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Addition", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.append", "Lib.Sequence.concat", "Lib.IntTypes.uint_t", "Lib.IntTypes.numbytes", "Lib.ByteSequence.uint_to_bytes_le", "Lib.IntTypes.u16" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake_get_r n seed i =
let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n)
false
Vale.X64.Taint_Semantics.fst
Vale.X64.Taint_Semantics.mk_ins
val mk_ins (i: S.ins) : Pure S.code (requires True) (ensures fun c -> c == Ins i /\ i == normal i /\ S.machine_eval_ins_st i == normal (S.machine_eval_ins_st i) )
val mk_ins (i: S.ins) : Pure S.code (requires True) (ensures fun c -> c == Ins i /\ i == normal i /\ S.machine_eval_ins_st i == normal (S.machine_eval_ins_st i) )
let mk_ins (i:S.ins) : Pure S.code (requires True) (ensures fun c -> c == Ins i /\ i == normal i /\ S.machine_eval_ins_st i == normal (S.machine_eval_ins_st i) ) = normal_term_spec (S.machine_eval_ins_st i); Ins i
{ "file_name": "vale/code/arch/x64/Vale.X64.Taint_Semantics.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 22, "start_col": 0, "start_line": 13 }
module Vale.X64.Taint_Semantics open FStar.Mul open Vale.X64.Decls open Vale.X64.Machine_s open Vale.X64.Instruction_s module S = Vale.X64.Machine_Semantics_s module L = FStar.List.Tot let normal_term_spec (#a:Type) (x:a) : Lemma (normal x == x) = ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.Decls.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Taint_Semantics.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Vale.X64.Machine_Semantics_s.ins -> Prims.Pure Vale.X64.Machine_Semantics_s.code
Prims.Pure
[]
[]
[ "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Prims.unit", "Vale.X64.Taint_Semantics.normal_term_spec", "Vale.X64.Machine_Semantics_s.st", "Vale.X64.Machine_Semantics_s.machine_eval_ins_st", "Vale.X64.Machine_Semantics_s.code", "Prims.l_True", "Prims.l_and", "Prims.eq2", "Vale.X64.Machine_s.precode", "Vale.X64.Instruction_s.normal" ]
[]
false
false
false
false
false
let mk_ins (i: S.ins) : Pure S.code (requires True) (ensures fun c -> c == Ins i /\ i == normal i /\ S.machine_eval_ins_st i == normal (S.machine_eval_ins_st i) ) =
normal_term_spec (S.machine_eval_ins_st i); Ins i
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake1_ind
val frodo_gen_matrix_shake1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let res_i = frodo_gen_matrix_shake_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res)
val frodo_gen_matrix_shake1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let res_i = frodo_gen_matrix_shake_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res)
let frodo_gen_matrix_shake1_ind n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in //Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}). res0.(i0, j) == res.(i0, j)) /\ (forall (j0:size_nat{j0 < j}). res0.(i, j0) == frodo_gen_matrix_shake_fc n seed i j0)) (frodo_gen_matrix_shake0 n i res_i) res
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 190, "start_col": 0, "start_line": 182 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3 val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x1 n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake_4x n seed = let res = Matrix.create n n in let n4 = n / 4 in Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res val frodo_gen_matrix_aes: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_aes n seed = let res = Matrix.create n n in let key = aes128_key_expansion seed in let tmp = LSeq.create 8 (u16 0) in let n1 = n / 8 in Loops.repeati n (fun i res -> Loops.repeati n1 (fun j res -> let j = j * 8 in let tmp = tmp.[0] <- u16 i in let tmp = tmp.[1] <- u16 j in let res_i = aes_encrypt_block AES128 key (uints_to_bytes_le tmp) in Loops.repeati 8 (fun k res -> res.(i, j + k) <- uint_from_bytes_le (LSeq.sub res_i (k * 2) 2) ) res ) res ) res (** Lemma (frodo_gen_matrix_shake == frodo_gen_matrix_shake_4x) *) val frodo_gen_matrix_shake_fc: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> j:size_nat{j < n} -> GTot uint16 let frodo_gen_matrix_shake_fc n seed i j = let res_i = frodo_gen_matrix_shake_get_r n seed i in uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let res_i = frodo_gen_matrix_shake_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res)
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> i: Lib.IntTypes.size_nat{i < n} -> res: Spec.Matrix.matrix n n -> Prims.Pure (Spec.Matrix.matrix n n)
Prims.Pure
[]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Prims.op_LessThan", "Spec.Matrix.matrix", "Lib.LoopCombinators.repeati_inductive'", "Prims.nat", "Prims.l_Forall", "Prims.eq2", "Spec.Matrix.elem", "Spec.Matrix.op_Array_Access", "FStar.Pervasives.Native.Mktuple2", "Lib.IntTypes.uint16", "Spec.Frodo.Gen.frodo_gen_matrix_shake_fc", "Spec.Frodo.Gen.frodo_gen_matrix_shake0", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Spec.Frodo.Gen.frodo_gen_matrix_shake_get_r" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake1_ind n seed i res =
let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0: size_nat{i0 < i}) (j: size_nat{j < n}). res0.(i0, j) == res.(i0, j)) /\ (forall (j0: size_nat{j0 < j}). res0.(i, j0) == frodo_gen_matrix_shake_fc n seed i j0)) (frodo_gen_matrix_shake0 n i res_i) res
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.lemma_gen_matrix_4x
val lemma_gen_matrix_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> res:matrix n n -> Lemma (requires (forall (i0:size_nat{i0 < n / 4}) (j:size_nat{j < n}) (k:size_nat{k < 4}). res.(4 * i0 + k, j) == frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j)) (ensures (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j))
val lemma_gen_matrix_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> res:matrix n n -> Lemma (requires (forall (i0:size_nat{i0 < n / 4}) (j:size_nat{j < n}) (k:size_nat{k < 4}). res.(4 * i0 + k, j) == frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j)) (ensures (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j))
let lemma_gen_matrix_4x n seed res = assert (forall (i0:size_nat{i0 < n / 4}) (j:size_nat{j < n}) (k:size_nat{k < 4}). frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j == frodo_gen_matrix_shake_fc n seed (i0 * 4 + k) j); assert (forall (i:size_nat{i < n}) (j:size_nat{j < n}). i == i / 4 * 4 + i % 4 /\ i / 4 < n / 4 /\ i % 4 < 4); assert (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed (i / 4 * 4 + i % 4) j)
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 127, "end_line": 251, "start_col": 0, "start_line": 247 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3 val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x1 n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake_4x n seed = let res = Matrix.create n n in let n4 = n / 4 in Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res val frodo_gen_matrix_aes: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_aes n seed = let res = Matrix.create n n in let key = aes128_key_expansion seed in let tmp = LSeq.create 8 (u16 0) in let n1 = n / 8 in Loops.repeati n (fun i res -> Loops.repeati n1 (fun j res -> let j = j * 8 in let tmp = tmp.[0] <- u16 i in let tmp = tmp.[1] <- u16 j in let res_i = aes_encrypt_block AES128 key (uints_to_bytes_le tmp) in Loops.repeati 8 (fun k res -> res.(i, j + k) <- uint_from_bytes_le (LSeq.sub res_i (k * 2) 2) ) res ) res ) res (** Lemma (frodo_gen_matrix_shake == frodo_gen_matrix_shake_4x) *) val frodo_gen_matrix_shake_fc: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> j:size_nat{j < n} -> GTot uint16 let frodo_gen_matrix_shake_fc n seed i j = let res_i = frodo_gen_matrix_shake_get_r n seed i in uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let res_i = frodo_gen_matrix_shake_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res) let frodo_gen_matrix_shake1_ind n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in //Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}). res0.(i0, j) == res.(i0, j)) /\ (forall (j0:size_nat{j0 < j}). res0.(i, j0) == frodo_gen_matrix_shake_fc n seed i j0)) (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> Pure (matrix n n) (requires True) (ensures fun res -> res == Loops.repeati n (frodo_gen_matrix_shake1_ind n seed) (Matrix.create n n) /\ (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j)) let frodo_gen_matrix_shake_ind n seed = let res = Matrix.create n n in //Loops.repeati n (frodo_gen_matrix_shake1 n seed) res Loops.repeati_inductive' #(matrix n n) n (fun i res -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}). res.(i0, j) == frodo_gen_matrix_shake_fc n seed i0 j) (frodo_gen_matrix_shake1_ind n seed) res val frodo_gen_matrix_shake_4x1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res) let frodo_gen_matrix_shake_4x1_ind n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in //Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}) (k:size_nat{k < 4}). res0.(4 * i0 + k, j) == res.(4 * i0 + k, j)) /\ (forall (j0:size_nat{j0 < j}) (k:size_nat{k < 4}). res0.(4 * i + k, j0) == frodo_gen_matrix_shake_fc n seed (4 * i + k) j0)) (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val lemma_gen_matrix_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> res:matrix n n -> Lemma (requires (forall (i0:size_nat{i0 < n / 4}) (j:size_nat{j < n}) (k:size_nat{k < 4}). res.(4 * i0 + k, j) == frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j)) (ensures (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j))
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16 /\ n % 4 = 0} -> seed: Lib.ByteSequence.lbytes 16 -> res: Spec.Matrix.matrix n n -> FStar.Pervasives.Lemma (requires forall (i0: Lib.IntTypes.size_nat{i0 < n / 4}) (j: Lib.IntTypes.size_nat{j < n}) (k: Lib.IntTypes.size_nat{k < 4}). res.(4 * i0 + k, j) == Spec.Frodo.Gen.frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j) (ensures forall (i: Lib.IntTypes.size_nat{i < n}) (j: Lib.IntTypes.size_nat{j < n}). res.(i, j) == Spec.Frodo.Gen.frodo_gen_matrix_shake_fc n seed i j)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "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.ByteSequence.lbytes", "Spec.Matrix.matrix", "Prims._assert", "Prims.l_Forall", "Prims.op_LessThan", "Prims.eq2", "Lib.IntTypes.uint16", "Spec.Matrix.op_Array_Access", "FStar.Pervasives.Native.Mktuple2", "Spec.Frodo.Gen.frodo_gen_matrix_shake_fc", "Prims.op_Addition", "Prims.op_Division", "Prims.unit" ]
[]
false
false
true
false
false
let lemma_gen_matrix_4x n seed res =
assert (forall (i0: size_nat{i0 < n / 4}) (j: size_nat{j < n}) (k: size_nat{k < 4}). frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j == frodo_gen_matrix_shake_fc n seed (i0 * 4 + k) j); assert (forall (i: size_nat{i < n}) (j: size_nat{j < n}). i == (i / 4) * 4 + i % 4 /\ i / 4 < n / 4 /\ i % 4 < 4); assert (forall (i: size_nat{i < n}) (j: size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed ((i / 4) * 4 + i % 4) j)
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_aes
val frodo_gen_matrix_aes: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n
val frodo_gen_matrix_aes: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n
let frodo_gen_matrix_aes n seed = let res = Matrix.create n n in let key = aes128_key_expansion seed in let tmp = LSeq.create 8 (u16 0) in let n1 = n / 8 in Loops.repeati n (fun i res -> Loops.repeati n1 (fun j res -> let j = j * 8 in let tmp = tmp.[0] <- u16 i in let tmp = tmp.[1] <- u16 j in let res_i = aes_encrypt_block AES128 key (uints_to_bytes_le tmp) in Loops.repeati 8 (fun k res -> res.(i, j + k) <- uint_from_bytes_le (LSeq.sub res_i (k * 2) 2) ) res ) res ) res
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 154, "start_col": 0, "start_line": 136 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3 val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x1 n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake_4x n seed = let res = Matrix.create n n in let n4 = n / 4 in Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res val frodo_gen_matrix_aes: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> Spec.Matrix.matrix n n
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Lib.LoopCombinators.repeati", "Spec.Matrix.matrix", "Prims.nat", "Prims.op_LessThan", "Spec.Matrix.op_Array_Assignment", "FStar.Pervasives.Native.Mktuple2", "Prims.op_Addition", "Lib.ByteSequence.uint_from_bytes_le", "Lib.IntTypes.SEC", "Lib.Sequence.sub", "Spec.AES.elem", "Spec.AES.block", "Spec.AES.aes_encrypt_block", "Spec.AES.AES128", "Lib.ByteSequence.uints_to_bytes_le", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Lib.IntTypes.mk_int", "Lib.Sequence.index", "Prims.l_Forall", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.uint_t", "Lib.IntTypes.u16", "Prims.int", "Prims.op_Division", "FStar.Seq.Base.create", "Lib.Sequence.create", "Prims.op_Multiply", "Spec.AES.aes128_key_expansion", "Spec.Matrix.create" ]
[]
false
false
false
false
false
let frodo_gen_matrix_aes n seed =
let res = Matrix.create n n in let key = aes128_key_expansion seed in let tmp = LSeq.create 8 (u16 0) in let n1 = n / 8 in Loops.repeati n (fun i res -> Loops.repeati n1 (fun j res -> let j = j * 8 in let tmp = tmp.[ 0 ] <- u16 i in let tmp = tmp.[ 1 ] <- u16 j in let res_i = aes_encrypt_block AES128 key (uints_to_bytes_le tmp) in Loops.repeati 8 (fun k res -> res.(i, j + k) <- uint_from_bytes_le (LSeq.sub res_i (k * 2) 2)) res) res) res
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake_4x_lemma
val frodo_gen_matrix_shake_4x_lemma: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> Lemma (frodo_gen_matrix_shake_4x n seed == frodo_gen_matrix_shake n seed)
val frodo_gen_matrix_shake_4x_lemma: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> Lemma (frodo_gen_matrix_shake_4x n seed == frodo_gen_matrix_shake n seed)
let frodo_gen_matrix_shake_4x_lemma n seed = let res = Matrix.create n n in let r_4x = frodo_gen_matrix_shake_4x n seed in let r = frodo_gen_matrix_shake n seed in let r_ind_4x = frodo_gen_matrix_shake_4x_ind n seed in let r_ind = frodo_gen_matrix_shake_ind n seed in assert (r_ind_4x == r_ind); assert (r_ind == Loops.repeati n (frodo_gen_matrix_shake1_ind n seed) res); assert (r_ind_4x == Loops.repeati (n / 4) (frodo_gen_matrix_shake_4x1_ind n seed) res); let aux_r (i:nat{i < n}) (acc:matrix n n) : Lemma (frodo_gen_matrix_shake1_ind n seed i acc == frodo_gen_matrix_shake1 n seed i acc) = () in Classical.forall_intro_2 aux_r; Lib.Sequence.Lemmas.repeati_extensionality n (frodo_gen_matrix_shake1_ind n seed) (frodo_gen_matrix_shake1 n seed) res; assert (r_ind == frodo_gen_matrix_shake n seed); let aux_r_4x (i:nat{i < n / 4}) (acc:matrix n n) : Lemma (frodo_gen_matrix_shake_4x1_ind n seed i acc == frodo_gen_matrix_shake_4x1 n seed i acc) = () in Classical.forall_intro_2 aux_r_4x; Lib.Sequence.Lemmas.repeati_extensionality (n / 4) (frodo_gen_matrix_shake_4x1_ind n seed) (frodo_gen_matrix_shake_4x1 n seed) res; assert (r_ind_4x == frodo_gen_matrix_shake_4x n seed); assert (r_4x == r)
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 20, "end_line": 312, "start_col": 0, "start_line": 286 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3 val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x1 n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake_4x n seed = let res = Matrix.create n n in let n4 = n / 4 in Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res val frodo_gen_matrix_aes: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_aes n seed = let res = Matrix.create n n in let key = aes128_key_expansion seed in let tmp = LSeq.create 8 (u16 0) in let n1 = n / 8 in Loops.repeati n (fun i res -> Loops.repeati n1 (fun j res -> let j = j * 8 in let tmp = tmp.[0] <- u16 i in let tmp = tmp.[1] <- u16 j in let res_i = aes_encrypt_block AES128 key (uints_to_bytes_le tmp) in Loops.repeati 8 (fun k res -> res.(i, j + k) <- uint_from_bytes_le (LSeq.sub res_i (k * 2) 2) ) res ) res ) res (** Lemma (frodo_gen_matrix_shake == frodo_gen_matrix_shake_4x) *) val frodo_gen_matrix_shake_fc: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> j:size_nat{j < n} -> GTot uint16 let frodo_gen_matrix_shake_fc n seed i j = let res_i = frodo_gen_matrix_shake_get_r n seed i in uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let res_i = frodo_gen_matrix_shake_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res) let frodo_gen_matrix_shake1_ind n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in //Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}). res0.(i0, j) == res.(i0, j)) /\ (forall (j0:size_nat{j0 < j}). res0.(i, j0) == frodo_gen_matrix_shake_fc n seed i j0)) (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> Pure (matrix n n) (requires True) (ensures fun res -> res == Loops.repeati n (frodo_gen_matrix_shake1_ind n seed) (Matrix.create n n) /\ (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j)) let frodo_gen_matrix_shake_ind n seed = let res = Matrix.create n n in //Loops.repeati n (frodo_gen_matrix_shake1 n seed) res Loops.repeati_inductive' #(matrix n n) n (fun i res -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}). res.(i0, j) == frodo_gen_matrix_shake_fc n seed i0 j) (frodo_gen_matrix_shake1_ind n seed) res val frodo_gen_matrix_shake_4x1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res) let frodo_gen_matrix_shake_4x1_ind n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in //Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}) (k:size_nat{k < 4}). res0.(4 * i0 + k, j) == res.(4 * i0 + k, j)) /\ (forall (j0:size_nat{j0 < j}) (k:size_nat{k < 4}). res0.(4 * i + k, j0) == frodo_gen_matrix_shake_fc n seed (4 * i + k) j0)) (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val lemma_gen_matrix_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> res:matrix n n -> Lemma (requires (forall (i0:size_nat{i0 < n / 4}) (j:size_nat{j < n}) (k:size_nat{k < 4}). res.(4 * i0 + k, j) == frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j)) (ensures (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j)) let lemma_gen_matrix_4x n seed res = assert (forall (i0:size_nat{i0 < n / 4}) (j:size_nat{j < n}) (k:size_nat{k < 4}). frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j == frodo_gen_matrix_shake_fc n seed (i0 * 4 + k) j); assert (forall (i:size_nat{i < n}) (j:size_nat{j < n}). i == i / 4 * 4 + i % 4 /\ i / 4 < n / 4 /\ i % 4 < 4); assert (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed (i / 4 * 4 + i % 4) j) val frodo_gen_matrix_shake_4x_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> Pure (matrix n n) (requires True) (ensures fun res -> res == Loops.repeati (n / 4) (frodo_gen_matrix_shake_4x1_ind n seed) (Matrix.create n n) /\ res == frodo_gen_matrix_shake_ind n seed) let frodo_gen_matrix_shake_4x_ind n seed = let res = Matrix.create n n in let n4 = n / 4 in //Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res let res = Loops.repeati_inductive' n4 (fun i res -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}) (k:size_nat{k < 4}). res.(4 * i0 + k, j) == frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j) (frodo_gen_matrix_shake_4x1_ind n seed) res in //assert (forall (i0:size_nat{i0 < n / 4}) (j:size_nat{j < n}) (k:size_nat{k < 4}). //res.(4 * i0 + k, j) == frodo_gen_matrix_shake_fc n seed (4 * i0 + k) j); lemma_gen_matrix_4x n seed res; Spec.Matrix.extensionality res (frodo_gen_matrix_shake_ind n seed); res val frodo_gen_matrix_shake_4x_lemma: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> Lemma (frodo_gen_matrix_shake_4x n seed == frodo_gen_matrix_shake n seed)
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16 /\ n % 4 = 0} -> seed: Lib.ByteSequence.lbytes 16 -> FStar.Pervasives.Lemma (ensures Spec.Frodo.Gen.frodo_gen_matrix_shake_4x n seed == Spec.Frodo.Gen.frodo_gen_matrix_shake n seed)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "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.ByteSequence.lbytes", "Prims._assert", "Prims.eq2", "Spec.Matrix.matrix", "Prims.unit", "Spec.Frodo.Gen.frodo_gen_matrix_shake_4x", "Lib.Sequence.Lemmas.repeati_extensionality", "Prims.op_Division", "Spec.Frodo.Gen.frodo_gen_matrix_shake_4x1_ind", "Spec.Frodo.Gen.frodo_gen_matrix_shake_4x1", "FStar.Classical.forall_intro_2", "Prims.nat", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Spec.Frodo.Gen.frodo_gen_matrix_shake", "Spec.Frodo.Gen.frodo_gen_matrix_shake1_ind", "Spec.Frodo.Gen.frodo_gen_matrix_shake1", "Lib.LoopCombinators.repeati", "Spec.Frodo.Gen.frodo_gen_matrix_shake_ind", "Spec.Frodo.Gen.frodo_gen_matrix_shake_4x_ind", "Spec.Matrix.create" ]
[]
false
false
true
false
false
let frodo_gen_matrix_shake_4x_lemma n seed =
let res = Matrix.create n n in let r_4x = frodo_gen_matrix_shake_4x n seed in let r = frodo_gen_matrix_shake n seed in let r_ind_4x = frodo_gen_matrix_shake_4x_ind n seed in let r_ind = frodo_gen_matrix_shake_ind n seed in assert (r_ind_4x == r_ind); assert (r_ind == Loops.repeati n (frodo_gen_matrix_shake1_ind n seed) res); assert (r_ind_4x == Loops.repeati (n / 4) (frodo_gen_matrix_shake_4x1_ind n seed) res); let aux_r (i: nat{i < n}) (acc: matrix n n) : Lemma (frodo_gen_matrix_shake1_ind n seed i acc == frodo_gen_matrix_shake1 n seed i acc) = () in Classical.forall_intro_2 aux_r; Lib.Sequence.Lemmas.repeati_extensionality n (frodo_gen_matrix_shake1_ind n seed) (frodo_gen_matrix_shake1 n seed) res; assert (r_ind == frodo_gen_matrix_shake n seed); let aux_r_4x (i: nat{i < n / 4}) (acc: matrix n n) : Lemma (frodo_gen_matrix_shake_4x1_ind n seed i acc == frodo_gen_matrix_shake_4x1 n seed i acc) = () in Classical.forall_intro_2 aux_r_4x; Lib.Sequence.Lemmas.repeati_extensionality (n / 4) (frodo_gen_matrix_shake_4x1_ind n seed) (frodo_gen_matrix_shake_4x1 n seed) res; assert (r_ind_4x == frodo_gen_matrix_shake_4x n seed); assert (r_4x == r)
false
Lib.ByteSequence.fsti
Lib.ByteSequence.lbytes
val lbytes : len: Lib.IntTypes.size_nat -> Type0
let lbytes (len:size_nat) = lbytes_l SEC len
{ "file_name": "lib/Lib.ByteSequence.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 19, "start_col": 29, "start_line": 19 }
module Lib.ByteSequence open FStar.Mul open Lib.IntTypes open Lib.Sequence #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0" /// Definition of byte-based sequences unfold inline_for_extraction type bytes_l (l:secrecy_level) = seq (uint_t U8 l) unfold inline_for_extraction type lbytes_l (l:secrecy_level) (len:size_nat) = lseq (uint_t U8 l) len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.ByteSequence.fsti" }
[ { "abbrev": false, "full_module": "Lib.Sequence", "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": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_nat -> Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Lib.ByteSequence.lbytes_l", "Lib.IntTypes.SEC" ]
[]
false
false
false
true
true
let lbytes (len: size_nat) =
lbytes_l SEC len
false
Lib.ByteSequence.fsti
Lib.ByteSequence.bytes
val bytes : Type0
let bytes = bytes_l SEC
{ "file_name": "lib/Lib.ByteSequence.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 18, "start_col": 29, "start_line": 18 }
module Lib.ByteSequence open FStar.Mul open Lib.IntTypes open Lib.Sequence #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0" /// Definition of byte-based sequences unfold inline_for_extraction type bytes_l (l:secrecy_level) = seq (uint_t U8 l) unfold inline_for_extraction type lbytes_l (l:secrecy_level) (len:size_nat) = lseq (uint_t U8 l) len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.ByteSequence.fsti" }
[ { "abbrev": false, "full_module": "Lib.Sequence", "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": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.ByteSequence.bytes_l", "Lib.IntTypes.SEC" ]
[]
false
false
false
true
true
let bytes =
bytes_l SEC
false
Lib.ByteSequence.fsti
Lib.ByteSequence.pub_bytes
val pub_bytes : Type0
let pub_bytes = bytes_l PUB
{ "file_name": "lib/Lib.ByteSequence.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 56, "end_line": 20, "start_col": 29, "start_line": 20 }
module Lib.ByteSequence open FStar.Mul open Lib.IntTypes open Lib.Sequence #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0" /// Definition of byte-based sequences unfold inline_for_extraction type bytes_l (l:secrecy_level) = seq (uint_t U8 l) unfold inline_for_extraction type lbytes_l (l:secrecy_level) (len:size_nat) = lseq (uint_t U8 l) len unfold inline_for_extraction let bytes = bytes_l SEC
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.ByteSequence.fsti" }
[ { "abbrev": false, "full_module": "Lib.Sequence", "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": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.ByteSequence.bytes_l", "Lib.IntTypes.PUB" ]
[]
false
false
false
true
true
let pub_bytes =
bytes_l PUB
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake_ind
val frodo_gen_matrix_shake_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> Pure (matrix n n) (requires True) (ensures fun res -> res == Loops.repeati n (frodo_gen_matrix_shake1_ind n seed) (Matrix.create n n) /\ (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j))
val frodo_gen_matrix_shake_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> Pure (matrix n n) (requires True) (ensures fun res -> res == Loops.repeati n (frodo_gen_matrix_shake1_ind n seed) (Matrix.create n n) /\ (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j))
let frodo_gen_matrix_shake_ind n seed = let res = Matrix.create n n in //Loops.repeati n (frodo_gen_matrix_shake1 n seed) res Loops.repeati_inductive' #(matrix n n) n (fun i res -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}). res.(i0, j) == frodo_gen_matrix_shake_fc n seed i0 j) (frodo_gen_matrix_shake1_ind n seed) res
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 211, "start_col": 0, "start_line": 203 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3 val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x1 n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake_4x n seed = let res = Matrix.create n n in let n4 = n / 4 in Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res val frodo_gen_matrix_aes: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_aes n seed = let res = Matrix.create n n in let key = aes128_key_expansion seed in let tmp = LSeq.create 8 (u16 0) in let n1 = n / 8 in Loops.repeati n (fun i res -> Loops.repeati n1 (fun j res -> let j = j * 8 in let tmp = tmp.[0] <- u16 i in let tmp = tmp.[1] <- u16 j in let res_i = aes_encrypt_block AES128 key (uints_to_bytes_le tmp) in Loops.repeati 8 (fun k res -> res.(i, j + k) <- uint_from_bytes_le (LSeq.sub res_i (k * 2) 2) ) res ) res ) res (** Lemma (frodo_gen_matrix_shake == frodo_gen_matrix_shake_4x) *) val frodo_gen_matrix_shake_fc: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> j:size_nat{j < n} -> GTot uint16 let frodo_gen_matrix_shake_fc n seed i j = let res_i = frodo_gen_matrix_shake_get_r n seed i in uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let res_i = frodo_gen_matrix_shake_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res) let frodo_gen_matrix_shake1_ind n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in //Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}). res0.(i0, j) == res.(i0, j)) /\ (forall (j0:size_nat{j0 < j}). res0.(i, j0) == frodo_gen_matrix_shake_fc n seed i j0)) (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> Pure (matrix n n) (requires True) (ensures fun res -> res == Loops.repeati n (frodo_gen_matrix_shake1_ind n seed) (Matrix.create n n) /\ (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j))
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> Prims.Pure (Spec.Matrix.matrix n n)
Prims.Pure
[]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Lib.LoopCombinators.repeati_inductive'", "Spec.Matrix.matrix", "Prims.nat", "Prims.l_Forall", "Prims.op_LessThan", "Prims.eq2", "Lib.IntTypes.uint16", "Spec.Matrix.op_Array_Access", "FStar.Pervasives.Native.Mktuple2", "Spec.Frodo.Gen.frodo_gen_matrix_shake_fc", "Spec.Frodo.Gen.frodo_gen_matrix_shake1_ind", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Spec.Matrix.create" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake_ind n seed =
let res = Matrix.create n n in Loops.repeati_inductive' #(matrix n n) n (fun i res -> forall (i0: size_nat{i0 < i}) (j: size_nat{j < n}). res.(i0, j) == frodo_gen_matrix_shake_fc n seed i0 j) (frodo_gen_matrix_shake1_ind n seed) res
false
Lib.ByteSequence.fsti
Lib.ByteSequence.pub_lbytes
val pub_lbytes : len: Lib.IntTypes.size_nat -> Type0
let pub_lbytes (len:size_nat) = lbytes_l PUB len
{ "file_name": "lib/Lib.ByteSequence.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 77, "end_line": 21, "start_col": 29, "start_line": 21 }
module Lib.ByteSequence open FStar.Mul open Lib.IntTypes open Lib.Sequence #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0" /// Definition of byte-based sequences unfold inline_for_extraction type bytes_l (l:secrecy_level) = seq (uint_t U8 l) unfold inline_for_extraction type lbytes_l (l:secrecy_level) (len:size_nat) = lseq (uint_t U8 l) len unfold inline_for_extraction let bytes = bytes_l SEC unfold inline_for_extraction let lbytes (len:size_nat) = lbytes_l SEC len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.ByteSequence.fsti" }
[ { "abbrev": false, "full_module": "Lib.Sequence", "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": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_nat -> Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Lib.ByteSequence.lbytes_l", "Lib.IntTypes.PUB" ]
[]
false
false
false
true
true
let pub_lbytes (len: size_nat) =
lbytes_l PUB len
false
Lib.ByteSequence.fsti
Lib.ByteSequence.bytes_t
val bytes_t : Type0
let bytes_t = bytes
{ "file_name": "lib/Lib.ByteSequence.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 24, "start_col": 29, "start_line": 24 }
module Lib.ByteSequence open FStar.Mul open Lib.IntTypes open Lib.Sequence #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0" /// Definition of byte-based sequences unfold inline_for_extraction type bytes_l (l:secrecy_level) = seq (uint_t U8 l) unfold inline_for_extraction type lbytes_l (l:secrecy_level) (len:size_nat) = lseq (uint_t U8 l) len unfold inline_for_extraction let bytes = bytes_l SEC unfold inline_for_extraction let lbytes (len:size_nat) = lbytes_l SEC len unfold inline_for_extraction let pub_bytes = bytes_l PUB unfold inline_for_extraction let pub_lbytes (len:size_nat) = lbytes_l PUB len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.ByteSequence.fsti" }
[ { "abbrev": false, "full_module": "Lib.Sequence", "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": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.ByteSequence.bytes" ]
[]
false
false
false
true
true
let bytes_t =
bytes
false
Lib.ByteSequence.fsti
Lib.ByteSequence.pub_bytes_t
val pub_bytes_t : Type0
let pub_bytes_t = pub_bytes
{ "file_name": "lib/Lib.ByteSequence.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 56, "end_line": 25, "start_col": 29, "start_line": 25 }
module Lib.ByteSequence open FStar.Mul open Lib.IntTypes open Lib.Sequence #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0" /// Definition of byte-based sequences unfold inline_for_extraction type bytes_l (l:secrecy_level) = seq (uint_t U8 l) unfold inline_for_extraction type lbytes_l (l:secrecy_level) (len:size_nat) = lseq (uint_t U8 l) len unfold inline_for_extraction let bytes = bytes_l SEC unfold inline_for_extraction let lbytes (len:size_nat) = lbytes_l SEC len unfold inline_for_extraction let pub_bytes = bytes_l PUB unfold inline_for_extraction let pub_lbytes (len:size_nat) = lbytes_l PUB len (* Alias *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.ByteSequence.fsti" }
[ { "abbrev": false, "full_module": "Lib.Sequence", "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": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.ByteSequence.pub_bytes" ]
[]
false
false
false
true
true
let pub_bytes_t =
pub_bytes
false
Spec.Frodo.Gen.fst
Spec.Frodo.Gen.frodo_gen_matrix_shake_4x1_ind
val frodo_gen_matrix_shake_4x1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res)
val frodo_gen_matrix_shake_4x1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res)
let frodo_gen_matrix_shake_4x1_ind n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in //Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}) (k:size_nat{k < 4}). res0.(4 * i0 + k, j) == res.(4 * i0 + k, j)) /\ (forall (j0:size_nat{j0 < j}) (k:size_nat{k < 4}). res0.(4 * i + k, j0) == frodo_gen_matrix_shake_fc n seed (4 * i + k) j0)) (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res
{ "file_name": "specs/frodo/Spec.Frodo.Gen.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 234, "start_col": 0, "start_line": 225 }
module Spec.Frodo.Gen open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix open Spec.SHA3 open Spec.AES module Matrix = Spec.Matrix module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val frodo_gen_matrix_shake_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> lbytes (2 * n) let frodo_gen_matrix_shake_get_r n seed i = let tmp = uint_to_bytes_le (u16 i) in let b = concat tmp seed in shake128 18 b (2 * n) val frodo_gen_matrix_shake0: n:size_nat{n * n <= max_size_t} -> i:size_nat{i < n} -> res_i:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake0 n i res_i j res0 = res0.(i, j) <- uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake1 n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake n seed = let res = Matrix.create n n in Loops.repeati n (frodo_gen_matrix_shake1 n seed) res val frodo_gen_matrix_shake_4x0: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> i:size_nat{i < n / 4} -> r0:lbytes (2 * n) -> r1:lbytes (2 * n) -> r2:lbytes (2 * n) -> r3:lbytes (2 * n) -> j:size_nat{j < n} -> res0:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3 j res0 = let res0 = res0.(4 * i + 0, j) <- uint_from_bytes_le (LSeq.sub r0 (j * 2) 2) in let res0 = res0.(4 * i + 1, j) <- uint_from_bytes_le (LSeq.sub r1 (j * 2) 2) in let res0 = res0.(4 * i + 2, j) <- uint_from_bytes_le (LSeq.sub r2 (j * 2) 2) in let res0 = res0.(4 * i + 3, j) <- uint_from_bytes_le (LSeq.sub r3 (j * 2) 2) in res0 val frodo_gen_matrix_shake_4x1_get_r: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) & lbytes (2 * n) let frodo_gen_matrix_shake_4x1_get_r n seed i = let t0 = uint_to_bytes_le (u16 (4 * i + 0)) in let t1 = uint_to_bytes_le (u16 (4 * i + 1)) in let t2 = uint_to_bytes_le (u16 (4 * i + 2)) in let t3 = uint_to_bytes_le (u16 (4 * i + 3)) in let b0 = concat t0 seed in let b1 = concat t1 seed in let b2 = concat t2 seed in let b3 = concat t3 seed in let r0 = shake128 18 b0 (2 * n) in let r1 = shake128 18 b1 (2 * n) in let r2 = shake128 18 b2 (2 * n) in let r3 = shake128 18 b3 (2 * n) in r0, r1, r2, r3 val frodo_gen_matrix_shake_4x1: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> matrix n n let frodo_gen_matrix_shake_4x1 n seed i res = let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res val frodo_gen_matrix_shake_4x: n:size_nat{n * n <= max_size_t /\ n <= maxint U16 /\ n % 4 = 0} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_shake_4x n seed = let res = Matrix.create n n in let n4 = n / 4 in Loops.repeati n4 (frodo_gen_matrix_shake_4x1 n seed) res val frodo_gen_matrix_aes: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> matrix n n let frodo_gen_matrix_aes n seed = let res = Matrix.create n n in let key = aes128_key_expansion seed in let tmp = LSeq.create 8 (u16 0) in let n1 = n / 8 in Loops.repeati n (fun i res -> Loops.repeati n1 (fun j res -> let j = j * 8 in let tmp = tmp.[0] <- u16 i in let tmp = tmp.[1] <- u16 j in let res_i = aes_encrypt_block AES128 key (uints_to_bytes_le tmp) in Loops.repeati 8 (fun k res -> res.(i, j + k) <- uint_from_bytes_le (LSeq.sub res_i (k * 2) 2) ) res ) res ) res (** Lemma (frodo_gen_matrix_shake == frodo_gen_matrix_shake_4x) *) val frodo_gen_matrix_shake_fc: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> j:size_nat{j < n} -> GTot uint16 let frodo_gen_matrix_shake_fc n seed i j = let res_i = frodo_gen_matrix_shake_get_r n seed i in uint_from_bytes_le (LSeq.sub res_i (j * 2) 2) val frodo_gen_matrix_shake1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let res_i = frodo_gen_matrix_shake_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res) let frodo_gen_matrix_shake1_ind n seed i res = let res_i = frodo_gen_matrix_shake_get_r n seed i in //Loops.repeati n (frodo_gen_matrix_shake0 n i res_i) res Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}). res0.(i0, j) == res.(i0, j)) /\ (forall (j0:size_nat{j0 < j}). res0.(i, j0) == frodo_gen_matrix_shake_fc n seed i j0)) (frodo_gen_matrix_shake0 n i res_i) res val frodo_gen_matrix_shake_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> Pure (matrix n n) (requires True) (ensures fun res -> res == Loops.repeati n (frodo_gen_matrix_shake1_ind n seed) (Matrix.create n n) /\ (forall (i:size_nat{i < n}) (j:size_nat{j < n}). res.(i, j) == frodo_gen_matrix_shake_fc n seed i j)) let frodo_gen_matrix_shake_ind n seed = let res = Matrix.create n n in //Loops.repeati n (frodo_gen_matrix_shake1 n seed) res Loops.repeati_inductive' #(matrix n n) n (fun i res -> forall (i0:size_nat{i0 < i}) (j:size_nat{j < n}). res.(i0, j) == frodo_gen_matrix_shake_fc n seed i0 j) (frodo_gen_matrix_shake1_ind n seed) res val frodo_gen_matrix_shake_4x1_ind: n:size_nat{n * n <= max_size_t /\ n <= maxint U16} -> seed:lbytes 16 -> i:size_nat{i < n / 4} -> res:matrix n n -> Pure (matrix n n) (requires True) (ensures fun res1 -> let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in res1 == Loops.repeati n (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res)
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Matrix.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Gen.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "Matrix" }, { "abbrev": false, "full_module": "Spec.AES", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "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": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.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
n: Lib.IntTypes.size_nat {n * n <= Lib.IntTypes.max_size_t /\ n <= Lib.IntTypes.maxint Lib.IntTypes.U16} -> seed: Lib.ByteSequence.lbytes 16 -> i: Lib.IntTypes.size_nat{i < n / 4} -> res: Spec.Matrix.matrix n n -> Prims.Pure (Spec.Matrix.matrix n n)
Prims.Pure
[]
[]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Lib.ByteSequence.lbytes", "Prims.op_LessThan", "Prims.op_Division", "Spec.Matrix.matrix", "Lib.LoopCombinators.repeati_inductive'", "Prims.nat", "Prims.l_Forall", "Prims.eq2", "Spec.Matrix.elem", "Spec.Matrix.op_Array_Access", "FStar.Pervasives.Native.Mktuple2", "Prims.op_Addition", "Lib.IntTypes.uint16", "Spec.Frodo.Gen.frodo_gen_matrix_shake_fc", "Spec.Frodo.Gen.frodo_gen_matrix_shake_4x0", "FStar.Pervasives.Native.tuple4", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Spec.Frodo.Gen.frodo_gen_matrix_shake_4x1_get_r" ]
[]
false
false
false
false
false
let frodo_gen_matrix_shake_4x1_ind n seed i res =
let r0, r1, r2, r3 = frodo_gen_matrix_shake_4x1_get_r n seed i in Loops.repeati_inductive' #(matrix n n) n (fun j res0 -> (forall (i0: size_nat{i0 < i}) (j: size_nat{j < n}) (k: size_nat{k < 4}). res0.(4 * i0 + k, j) == res.(4 * i0 + k, j)) /\ (forall (j0: size_nat{j0 < j}) (k: size_nat{k < 4}). res0.(4 * i + k, j0) == frodo_gen_matrix_shake_fc n seed (4 * i + k) j0)) (frodo_gen_matrix_shake_4x0 n i r0 r1 r2 r3) res
false
Lib.ByteSequence.fsti
Lib.ByteSequence.pub_bytes_empty
val pub_bytes_empty:pub_bytes
val pub_bytes_empty:pub_bytes
let pub_bytes_empty: pub_bytes = Seq.Base.empty
{ "file_name": "lib/Lib.ByteSequence.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 60, "start_col": 0, "start_line": 60 }
module Lib.ByteSequence open FStar.Mul open Lib.IntTypes open Lib.Sequence #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0" /// Definition of byte-based sequences unfold inline_for_extraction type bytes_l (l:secrecy_level) = seq (uint_t U8 l) unfold inline_for_extraction type lbytes_l (l:secrecy_level) (len:size_nat) = lseq (uint_t U8 l) len unfold inline_for_extraction let bytes = bytes_l SEC unfold inline_for_extraction let lbytes (len:size_nat) = lbytes_l SEC len unfold inline_for_extraction let pub_bytes = bytes_l PUB unfold inline_for_extraction let pub_lbytes (len:size_nat) = lbytes_l PUB len (* Alias *) unfold inline_for_extraction let bytes_t = bytes unfold inline_for_extraction let pub_bytes_t = pub_bytes (** Construct the equality mask for a pair of secret integer sequences *) val seq_eq_mask: #t:inttype{~(S128? t)} -> #len1:size_nat -> #len2:size_nat -> b1:lseq (int_t t SEC) len1 -> b2:lseq (int_t t SEC) len2 -> len:size_nat{len <= len1 /\ len <= len2} -> res:int_t t SEC{ (sub b1 0 len == sub b2 0 len ==> v res == v (ones t SEC)) /\ (sub b1 0 len =!= sub b2 0 len ==> v res == v (zeros t SEC))} (** Compares two byte sequences and declassifies the result *) inline_for_extraction val lbytes_eq: #len:size_nat -> b1:lbytes len -> b2:lbytes len -> b:bool{b <==> b1 == b2} inline_for_extraction val mask_select: #t:inttype{~(S128? t)} -> mask:int_t t SEC -> a:int_t t SEC -> b:int_t t SEC -> int_t t SEC val mask_select_lemma: #t:inttype{~(S128? t)} -> mask:int_t t SEC -> a:int_t t SEC -> b:int_t t SEC -> Lemma (requires v mask = 0 \/ v mask = v (ones t SEC)) (ensures mask_select mask a b == (if v mask = 0 then b else a)) val seq_mask_select: #t:inttype{~(S128? t)} -> #len:size_nat -> a:lseq (int_t t SEC) len -> b:lseq (int_t t SEC) len -> mask:int_t t SEC -> Pure (lseq (int_t t SEC) len) (requires v mask = 0 \/ v mask = v (ones t SEC)) (ensures fun res -> res == (if v mask = 0 then b else a)) /// Constant for empty lbytes
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.ByteSequence.fsti" }
[ { "abbrev": false, "full_module": "Lib.Sequence", "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": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.seq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB)
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.empty", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.PUB" ]
[]
false
false
false
true
false
let pub_bytes_empty:pub_bytes =
Seq.Base.empty
false