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
LowParse.Low.Writers.fst
LowParse.Low.Writers.olwriter_nil
val olwriter_nil (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0}) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Tot (x: olwriter s h0 sout pout_from0 {olwvalue x == Some []})
val olwriter_nil (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0}) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Tot (x: olwriter s h0 sout pout_from0 {olwvalue x == Some []})
let olwriter_nil (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Tot (x: olwriter s h0 sout pout_from0 { olwvalue x == Some [] }) = OLWriter (Ghost.hide (Some [])) (fun pout_from -> let h = HST.get () in valid_list_nil p h sout pout_from; pout_from )
{ "file_name": "src/lowparse/LowParse.Low.Writers.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 758, "start_col": 0, "start_line": 744 }
module LowParse.Low.Writers include LowParse.Low.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module U32 = FStar.UInt32 module L = FStar.List.Tot inline_for_extraction noextract let fswriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ live_slice h sout /\ U32.v pout_from + serialized_length s x + space_beyond <= U32.v sout.len )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ valid_content_pos p h' sout pout_from x res )) inline_for_extraction noextract noeq type swriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | SWriter: (v: Ghost.erased t) -> (w: fswriter s h0 space_beyond sout pout_from0 (Ghost.reveal v)) -> swriter s h0 space_beyond sout pout_from0 let swvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#space_beyond: nat) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: swriter s h0 space_beyond sout pout_from0) : GTot t = Ghost.reveal w.v inline_for_extraction noextract let weaken_swriter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#space_beyond0: nat) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: swriter s h0 space_beyond0 sout pout_from0) (h1: HS.mem) (space_beyond1: nat) (pout_from1: U32.t) : Pure (w' : swriter s h1 space_beyond1 sout pout_from1 { swvalue w' == swvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1 /\ space_beyond0 <= space_beyond1)) (ensures (fun _ -> True)) = SWriter w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let swrite (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#space_beyond: nat) (w: swriter s h0 space_beyond sout pout_from0) : Tot (fswriter s h0 space_beyond sout pout_from0 (swvalue w)) = match w with | SWriter _ f -> f inline_for_extraction noextract let swriter_ifthenelse (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#space_beyond: nat) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (cond: bool) (wtrue: (squash (cond == true) -> Tot (swriter s h0 space_beyond sout pout_from0))) (wfalse: (squash (cond == false) -> Tot (swriter s h0 space_beyond sout pout_from0))) : Tot (x: swriter s h0 space_beyond sout pout_from0 { swvalue x == (if cond then swvalue (wtrue ()) else swvalue (wfalse ())) } ) = SWriter (if cond then SWriter?.v (wtrue ()) else SWriter?.v (wfalse ())) (fun pout_from -> if cond then swrite (wtrue ()) pout_from else swrite (wfalse ()) pout_from) inline_for_extraction noextract let swrite_leaf (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (w: leaf_writer_strong s) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot (y: swriter s h0 0 sout pout_from0 { swvalue y == x } ) = SWriter (Ghost.hide x) (fun pout_from -> w x sout pout_from) inline_for_extraction noextract let fwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ live_slice h sout /\ U32.v pout_from <= U32.v sout.len /\ U32.v sout.len < U32.v max_uint32 )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ ( if res = max_uint32 then U32.v pout_from + serialized_length s x > U32.v sout.len else valid_content_pos p h' sout pout_from x res ))) inline_for_extraction noextract noeq type writer (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | Writer: (v: Ghost.erased t) -> (w: fwriter s h0 sout pout_from0 (Ghost.reveal v)) -> writer s h0 sout pout_from0 let wvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) : GTot t = Ghost.reveal w.v inline_for_extraction noextract let weaken_writer (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) (h1: HS.mem) (pout_from1: U32.t) : Pure (w' : writer s h1 sout pout_from1 { wvalue w' == wvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1)) (ensures (fun _ -> True)) = Writer w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let write (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) : Tot (fwriter s h0 sout pout_from0 (wvalue w)) = match w with | Writer _ f -> f inline_for_extraction noextract let writer_ifthenelse (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (cond: bool) (wtrue: (squash (cond == true) -> Tot (writer s h0 sout pout_from0))) (wfalse: (squash (cond == false) -> Tot (writer s h0 sout pout_from0))) : Tot (x: writer s h0 sout pout_from0 { wvalue x == (if cond then wvalue (wtrue ()) else wvalue (wfalse ())) } ) = Writer (if cond then Writer?.v (wtrue ()) else Writer?.v (wfalse ())) (fun pout_from -> if cond then write (wtrue ()) pout_from else write (wfalse ()) pout_from) inline_for_extraction noextract let write_leaf_cs (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_low < 4294967296 } ) (w: leaf_writer_strong s) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot (y: writer s h0 sout pout_from0 { wvalue y == x } ) = Writer (Ghost.hide x) (fun pout_from -> if U32.uint_to_t k.parser_kind_low `U32.gt` (sout.len `U32.sub` pout_from) then max_uint32 else w x sout pout_from ) inline_for_extraction noextract let flwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: list t) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h sout /\ B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ U32.v pout_from <= U32.v sout.len /\ U32.v sout.len < U32.v max_uint32 )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ ( if res = max_uint32 then U32.v pout_from + serialized_list_length s x > U32.v sout.len else valid_list p h' sout pout_from res /\ contents_list p h' sout pout_from res == x ))) inline_for_extraction noeq noextract type lwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | LWriter: (v: Ghost.erased (list t)) -> (w: flwriter s h0 sout pout_from0 (Ghost.reveal v)) -> lwriter s h0 sout pout_from0 inline_for_extraction noextract let lwvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: lwriter s h0 sout pout_from0) : GTot (list t) = Ghost.reveal w.v inline_for_extraction noextract let weaken_lwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: lwriter s h0 sout pout_from0) (h1: HS.mem) (pout_from1: U32.t) : Pure (w' : lwriter s h1 sout pout_from1 { lwvalue w' == lwvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1)) (ensures (fun _ -> True)) = LWriter w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let lwrite (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: lwriter s h0 sout pout_from0) : Tot (flwriter s h0 sout pout_from0 (lwvalue w)) = match w with | LWriter _ f -> f inline_for_extraction noextract let lwriter_nil (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Tot (x: lwriter s h0 sout pout_from0 { lwvalue x == [] }) = LWriter (Ghost.hide []) (fun pout_from -> let h = HST.get () in valid_list_nil p h sout pout_from; pout_from ) inline_for_extraction noextract let lwriter_singleton (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) : Tot (x: lwriter s h0 sout pout_from0 { lwvalue x == [wvalue w] } ) = LWriter (Ghost.hide [wvalue w]) (fun pout_from -> let res = write w pout_from in if res `U32.lt` max_uint32 then begin let h = HST.get () in valid_list_nil p h sout res; valid_list_cons p h sout pout_from res end else begin [@inline_let] let f () : Lemma (ensures (let v = wvalue w in serialized_list_length s [v] == serialized_length s v)) = serialized_list_length_cons s (wvalue w) []; serialized_list_length_nil s in f () end; res ) inline_for_extraction noextract let lwriter_append (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w1 w2: lwriter s h0 sout pout_from0) : Tot (x: lwriter s h0 sout pout_from0 { lwvalue x == lwvalue w1 `List.Tot.append` lwvalue w2 } ) = LWriter (Ghost.hide (lwvalue w1 `List.Tot.append` lwvalue w2)) (fun pout_from -> let res1 = lwrite w1 pout_from in Classical.forall_intro_2 (serialized_list_length_append s); if res1 = max_uint32 then res1 else begin let res2 = lwrite w2 res1 in let h = HST.get () in valid_list_serialized_list_length s h sout pout_from res1; if res2 `U32.lt` (max_uint32) then begin valid_list_serialized_list_length s h sout res1 res2; valid_list_append p h sout pout_from res1 res2; valid_list_serialized_list_length s h sout pout_from res2 end; res2 end ) inline_for_extraction noextract let lwriter_ifthenelse (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (cond: bool) (wtrue: (squash (cond == true) -> Tot (lwriter s h0 sout pout_from0))) (wfalse: (squash (cond == false) -> Tot (lwriter s h0 sout pout_from0))) : Tot (x: lwriter s h0 sout pout_from0 { lwvalue x == (if cond then lwvalue (wtrue ()) else lwvalue (wfalse ())) } ) = LWriter (if cond then (wtrue ()).v else (wfalse ()).v) (fun pout_from -> if cond then lwrite (wtrue ()) pout_from else lwrite (wfalse ()) pout_from) inline_for_extraction noextract let lwriter_list_map (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (j1: jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong /\ k2.parser_kind_low > 0 } ) (f: t1 -> Tot t2) (#rrel #rel: _) (sin: slice rrel rel) (pin_from pin_to: U32.t) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t { B.loc_disjoint (loc_slice_from sout pout_from0) (loc_slice_from_to sin pin_from pin_to) /\ valid_list p1 h0 sin pin_from pin_to }) (f' : ( (pos: U32.t { U32.v pin_from <= U32.v pos /\ valid p1 h0 sin pos /\ U32.v pos + content_length p1 h0 sin pos <= U32.v pin_to }) -> Tot (y: writer s2 h0 sout pout_from0 { wvalue y == f (contents p1 h0 sin pos) }) )) : Tot (x: lwriter s2 h0 sout pout_from0 { lwvalue x == List.Tot.map f (contents_list p1 h0 sin pin_from pin_to) } ) = LWriter (Ghost.hide (List.Tot.map f (contents_list p1 h0 sin pin_from pin_to))) (fun pout_from -> assert (k1.parser_kind_subkind == Some ParserStrong); let h = HST.get () in list_map j1 s2 f h sin pin_from pin_to sout pout_from (fun pin_ pout_ -> valid_pos_frame_strong p1 h0 sin pin_ (get_valid_pos p1 h sin pin_) (loc_slice_from sout pout_from0) h; write (f' pin_) pout_ ) ) (* With options (other failures) *) inline_for_extraction noextract let fowriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: option t) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ live_slice h sout /\ U32.v pout_from <= U32.v sout.len /\ U32.v sout.len < U32.v max_uint32 - 1 )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ ( if res = max_uint32 then (Some? x ==> U32.v pout_from + serialized_length s (Some?.v x) > U32.v sout.len) else if res = max_uint32 `U32.sub` 1ul then None? x else Some? x /\ valid_content_pos p h' sout pout_from (Some?.v x) res ))) inline_for_extraction noextract noeq type owriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | OWriter: (v: Ghost.erased (option t)) -> (w: fowriter s h0 sout pout_from0 (Ghost.reveal v)) -> owriter s h0 sout pout_from0 let owvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: owriter s h0 sout pout_from0) : GTot (option t) = Ghost.reveal w.v inline_for_extraction noextract let weaken_owriter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: owriter s h0 sout pout_from0) (h1: HS.mem) (pout_from1: U32.t) : Pure (w' : owriter s h1 sout pout_from1 { owvalue w' == owvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1)) (ensures (fun _ -> True)) = OWriter w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let owrite (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: owriter s h0 sout pout_from0) : Tot (fowriter s h0 sout pout_from0 (owvalue w)) = match w with | OWriter _ f -> f inline_for_extraction noextract let owriter_ifthenelse (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (cond: bool) (wtrue: (squash (cond == true) -> Tot (owriter s h0 sout pout_from0))) (wfalse: (squash (cond == false) -> Tot (owriter s h0 sout pout_from0))) : Tot (x: owriter s h0 sout pout_from0 { owvalue x == (if cond then owvalue (wtrue ()) else owvalue (wfalse ())) } ) = OWriter (if cond then OWriter?.v (wtrue ()) else OWriter?.v (wfalse ())) (fun pout_from -> if cond then owrite (wtrue ()) pout_from else owrite (wfalse ()) pout_from) inline_for_extraction noextract let owrite_leaf_cs (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_low < 4294967296 } ) (w: leaf_writer_strong s) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot (y: owriter s h0 sout pout_from0 { owvalue y == Some x } ) = OWriter (Ghost.hide (Some x)) (fun pout_from -> if U32.uint_to_t k.parser_kind_low `U32.gt` (sout.len `U32.sub` pout_from) then max_uint32 else w x sout pout_from ) inline_for_extraction noextract let owriter_of_writer (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) : Tot (x: owriter s h0 sout pout_from0 { owvalue x == Some (wvalue w) }) = OWriter (Ghost.hide (Some (wvalue w))) (fun pout_from -> write w pout_from) inline_for_extraction noextract let folwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: option (list t)) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h sout /\ B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ U32.v pout_from <= U32.v sout.len /\ U32.v sout.len < U32.v max_uint32 - 1 )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ ( if res = max_uint32 then (Some? x ==> U32.v pout_from + serialized_list_length s (Some?.v x) > U32.v sout.len) else if res = max_uint32 `U32.sub` 1ul then None? x else Some? x /\ valid_list p h' sout pout_from res /\ contents_list p h' sout pout_from res == (Some?.v x) ))) inline_for_extraction noeq noextract type olwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | OLWriter: (v: Ghost.erased (option (list t))) -> (w: folwriter s h0 sout pout_from0 (Ghost.reveal v)) -> olwriter s h0 sout pout_from0 inline_for_extraction noextract let olwvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: olwriter s h0 sout pout_from0) : GTot (option (list t)) = Ghost.reveal w.v inline_for_extraction noextract let weaken_olwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: olwriter s h0 sout pout_from0) (h1: HS.mem) (pout_from1: U32.t) : Pure (w' : olwriter s h1 sout pout_from1 { olwvalue w' == olwvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1)) (ensures (fun _ -> True)) = OLWriter w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let olwrite (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: olwriter s h0 sout pout_from0) : Tot (folwriter s h0 sout pout_from0 (olwvalue w)) = match w with | OLWriter _ f -> f inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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 { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\ Mkparser_kind'?.parser_kind_low k > 0 } -> h0: FStar.Monotonic.HyperStack.mem -> sout: LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte )) (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte)) -> pout_from0: FStar.UInt32.t -> x: LowParse.Low.Writers.olwriter s h0 sout pout_from0 {LowParse.Low.Writers.olwvalue x == FStar.Pervasives.Native.Some []}
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.b2t", "Prims.op_GreaterThan", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "LowParse.Low.Writers.OLWriter", "FStar.Ghost.hide", "Prims.list", "Prims.Nil", "Prims.unit", "LowParse.Low.Base.Spec.valid_list_nil", "FStar.HyperStack.ST.get", "LowParse.Low.Writers.olwriter", "LowParse.Low.Writers.olwvalue" ]
[]
false
false
false
false
false
let olwriter_nil (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0}) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Tot (x: olwriter s h0 sout pout_from0 {olwvalue x == Some []}) =
OLWriter (Ghost.hide (Some [])) (fun pout_from -> let h = HST.get () in valid_list_nil p h sout pout_from; pout_from)
false
Spec.SHA3.fst
Spec.SHA3.shake128
val shake128 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) (outputByteLen: size_nat) : Tot (lbytes outputByteLen)
val shake128 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) (outputByteLen: size_nat) : Tot (lbytes outputByteLen)
let shake128 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1344 256 inputByteLen input (byte 0x1F) outputByteLen
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 208, "start_col": 0, "start_line": 202 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8) let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) = update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j]) let storeState (rateInBytes:size_nat{rateInBytes <= 200}) (s:state) : Tot (lbytes rateInBytes) = let block = create 200 (u8 0) in let block = repeati 25 (storeState_inner s) block in sub block 0 rateInBytes let absorb_next (s:state) (rateInBytes:size_nat{rateInBytes > 0 /\ rateInBytes <= 200}) : Tot state = let nextBlock = create rateInBytes (u8 0) in let nextBlock = nextBlock.[rateInBytes - 1] <- u8 0x80 in let s = loadState rateInBytes nextBlock s in state_permute s val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state let absorb_last delimitedSuffix rateInBytes rem input s = let lastBlock = create rateInBytes (u8 0) in let lastBlock = update_sub lastBlock 0 rem input in let lastBlock = lastBlock.[rem] <- byte_to_uint8 delimitedSuffix in let s = loadState rateInBytes lastBlock s in let s = if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (rem = rateInBytes - 1) then state_permute s else s in absorb_next s rateInBytes let absorb_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (block:lbytes rateInBytes) (s:state) : Tot state = let s = loadState rateInBytes block s in state_permute s let absorb (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (delimitedSuffix:byte_t) : Tot state = repeat_blocks rateInBytes input (absorb_inner rateInBytes) (absorb_last delimitedSuffix rateInBytes) s let squeeze_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat) (i:size_nat{i < outputByteLen / rateInBytes}) (s:state) : Tot (state & lbytes rateInBytes) = let block = storeState rateInBytes s in let s = state_permute s in s, block let squeeze (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat): Tot (lbytes outputByteLen) = let outBlocks = outputByteLen / rateInBytes in let a (i:nat{i <= outBlocks}) = state in let s, output = generate_blocks rateInBytes outBlocks outBlocks a (squeeze_inner rateInBytes outputByteLen) s in let remOut = outputByteLen % rateInBytes in let block = storeState remOut s in (to_lseq output) @| block val keccak: rate:size_nat{rate % 8 == 0 /\ rate / 8 > 0 /\ rate <= 1600} -> capacity:size_nat{capacity + rate == 1600} -> inputByteLen:nat -> input:bytes{length input == inputByteLen} -> delimitedSuffix:byte_t -> outputByteLen:size_nat -> Tot (lbytes outputByteLen) let keccak rate capacity inputByteLen input delimitedSuffix outputByteLen = let rateInBytes = rate / 8 in let s = create 25 (u64 0) in let s = absorb s rateInBytes inputByteLen input delimitedSuffix in squeeze s rateInBytes outputByteLen
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
inputByteLen: Prims.nat -> input: Lib.ByteSequence.bytes{Lib.Sequence.length input == inputByteLen} -> outputByteLen: Lib.IntTypes.size_nat -> Lib.ByteSequence.lbytes outputByteLen
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Lib.ByteSequence.bytes", "Prims.eq2", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.size_nat", "Spec.SHA3.keccak", "Lib.IntTypes.byte", "Lib.ByteSequence.lbytes" ]
[]
false
false
false
false
false
let shake128 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) (outputByteLen: size_nat) : Tot (lbytes outputByteLen) =
keccak 1344 256 inputByteLen input (byte 0x1F) outputByteLen
false
Spec.SHA3.fst
Spec.SHA3.shake256
val shake256 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) (outputByteLen: size_nat) : Tot (lbytes outputByteLen)
val shake256 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) (outputByteLen: size_nat) : Tot (lbytes outputByteLen)
let shake256 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1088 512 inputByteLen input (byte 0x1F) outputByteLen
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 216, "start_col": 0, "start_line": 210 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8) let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) = update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j]) let storeState (rateInBytes:size_nat{rateInBytes <= 200}) (s:state) : Tot (lbytes rateInBytes) = let block = create 200 (u8 0) in let block = repeati 25 (storeState_inner s) block in sub block 0 rateInBytes let absorb_next (s:state) (rateInBytes:size_nat{rateInBytes > 0 /\ rateInBytes <= 200}) : Tot state = let nextBlock = create rateInBytes (u8 0) in let nextBlock = nextBlock.[rateInBytes - 1] <- u8 0x80 in let s = loadState rateInBytes nextBlock s in state_permute s val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state let absorb_last delimitedSuffix rateInBytes rem input s = let lastBlock = create rateInBytes (u8 0) in let lastBlock = update_sub lastBlock 0 rem input in let lastBlock = lastBlock.[rem] <- byte_to_uint8 delimitedSuffix in let s = loadState rateInBytes lastBlock s in let s = if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (rem = rateInBytes - 1) then state_permute s else s in absorb_next s rateInBytes let absorb_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (block:lbytes rateInBytes) (s:state) : Tot state = let s = loadState rateInBytes block s in state_permute s let absorb (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (delimitedSuffix:byte_t) : Tot state = repeat_blocks rateInBytes input (absorb_inner rateInBytes) (absorb_last delimitedSuffix rateInBytes) s let squeeze_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat) (i:size_nat{i < outputByteLen / rateInBytes}) (s:state) : Tot (state & lbytes rateInBytes) = let block = storeState rateInBytes s in let s = state_permute s in s, block let squeeze (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat): Tot (lbytes outputByteLen) = let outBlocks = outputByteLen / rateInBytes in let a (i:nat{i <= outBlocks}) = state in let s, output = generate_blocks rateInBytes outBlocks outBlocks a (squeeze_inner rateInBytes outputByteLen) s in let remOut = outputByteLen % rateInBytes in let block = storeState remOut s in (to_lseq output) @| block val keccak: rate:size_nat{rate % 8 == 0 /\ rate / 8 > 0 /\ rate <= 1600} -> capacity:size_nat{capacity + rate == 1600} -> inputByteLen:nat -> input:bytes{length input == inputByteLen} -> delimitedSuffix:byte_t -> outputByteLen:size_nat -> Tot (lbytes outputByteLen) let keccak rate capacity inputByteLen input delimitedSuffix outputByteLen = let rateInBytes = rate / 8 in let s = create 25 (u64 0) in let s = absorb s rateInBytes inputByteLen input delimitedSuffix in squeeze s rateInBytes outputByteLen let shake128 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1344 256 inputByteLen input (byte 0x1F) outputByteLen
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
inputByteLen: Prims.nat -> input: Lib.ByteSequence.bytes{Lib.Sequence.length input == inputByteLen} -> outputByteLen: Lib.IntTypes.size_nat -> Lib.ByteSequence.lbytes outputByteLen
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Lib.ByteSequence.bytes", "Prims.eq2", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.size_nat", "Spec.SHA3.keccak", "Lib.IntTypes.byte", "Lib.ByteSequence.lbytes" ]
[]
false
false
false
false
false
let shake256 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) (outputByteLen: size_nat) : Tot (lbytes outputByteLen) =
keccak 1088 512 inputByteLen input (byte 0x1F) outputByteLen
false
Spec.SHA3.fst
Spec.SHA3.squeeze
val squeeze (s: state) (rateInBytes: size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen: size_nat) : Tot (lbytes outputByteLen)
val squeeze (s: state) (rateInBytes: size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen: size_nat) : Tot (lbytes outputByteLen)
let squeeze (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat): Tot (lbytes outputByteLen) = let outBlocks = outputByteLen / rateInBytes in let a (i:nat{i <= outBlocks}) = state in let s, output = generate_blocks rateInBytes outBlocks outBlocks a (squeeze_inner rateInBytes outputByteLen) s in let remOut = outputByteLen % rateInBytes in let block = storeState remOut s in (to_lseq output) @| block
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 184, "start_col": 0, "start_line": 170 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8) let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) = update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j]) let storeState (rateInBytes:size_nat{rateInBytes <= 200}) (s:state) : Tot (lbytes rateInBytes) = let block = create 200 (u8 0) in let block = repeati 25 (storeState_inner s) block in sub block 0 rateInBytes let absorb_next (s:state) (rateInBytes:size_nat{rateInBytes > 0 /\ rateInBytes <= 200}) : Tot state = let nextBlock = create rateInBytes (u8 0) in let nextBlock = nextBlock.[rateInBytes - 1] <- u8 0x80 in let s = loadState rateInBytes nextBlock s in state_permute s val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state let absorb_last delimitedSuffix rateInBytes rem input s = let lastBlock = create rateInBytes (u8 0) in let lastBlock = update_sub lastBlock 0 rem input in let lastBlock = lastBlock.[rem] <- byte_to_uint8 delimitedSuffix in let s = loadState rateInBytes lastBlock s in let s = if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (rem = rateInBytes - 1) then state_permute s else s in absorb_next s rateInBytes let absorb_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (block:lbytes rateInBytes) (s:state) : Tot state = let s = loadState rateInBytes block s in state_permute s let absorb (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (delimitedSuffix:byte_t) : Tot state = repeat_blocks rateInBytes input (absorb_inner rateInBytes) (absorb_last delimitedSuffix rateInBytes) s let squeeze_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat) (i:size_nat{i < outputByteLen / rateInBytes}) (s:state) : Tot (state & lbytes rateInBytes) = let block = storeState rateInBytes s in let s = state_permute s in s, block
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Spec.SHA3.state -> rateInBytes: Lib.IntTypes.size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> outputByteLen: Lib.IntTypes.size_nat -> Lib.ByteSequence.lbytes outputByteLen
Prims.Tot
[ "total" ]
[]
[ "Spec.SHA3.state", "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Lib.Sequence.seq", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star", "Lib.Sequence.op_At_Bar", "Lib.Sequence.to_lseq", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.SHA3.storeState", "Prims.op_Modulus", "Lib.ByteSequence.lbytes", "FStar.Pervasives.Native.tuple2", "Prims.op_Multiply", "Lib.Sequence.generate_blocks", "Spec.SHA3.squeeze_inner", "Prims.nat", "Prims.op_Division" ]
[]
false
false
false
false
false
let squeeze (s: state) (rateInBytes: size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen: size_nat) : Tot (lbytes outputByteLen) =
let outBlocks = outputByteLen / rateInBytes in let a (i: nat{i <= outBlocks}) = state in let s, output = generate_blocks rateInBytes outBlocks outBlocks a (squeeze_inner rateInBytes outputByteLen) s in let remOut = outputByteLen % rateInBytes in let block = storeState remOut s in (to_lseq output) @| block
false
Spec.SHA3.fst
Spec.SHA3.storeState_inner
val storeState_inner (s: state) (j: size_nat{j < 25}) (block: lbytes 200) : Tot (lbytes 200)
val storeState_inner (s: state) (j: size_nat{j < 25}) (block: lbytes 200) : Tot (lbytes 200)
let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) = update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j])
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 106, "start_col": 0, "start_line": 105 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8) let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Spec.SHA3.state -> j: Lib.IntTypes.size_nat{j < 25} -> block: Lib.ByteSequence.lbytes 200 -> Lib.ByteSequence.lbytes 200
Prims.Tot
[ "total" ]
[]
[ "Spec.SHA3.state", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThan", "Lib.ByteSequence.lbytes", "Lib.Sequence.update_sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Lib.ByteSequence.uint_to_bytes_le", "Lib.IntTypes.U64", "Lib.Sequence.op_String_Access", "Lib.IntTypes.uint64" ]
[]
false
false
false
false
false
let storeState_inner (s: state) (j: size_nat{j < 25}) (block: lbytes 200) : Tot (lbytes 200) =
update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[ j ])
false
Spec.SHA3.fst
Spec.SHA3.loadState
val loadState (rateInBytes: size_nat{rateInBytes <= 200}) (input: lbytes rateInBytes) (s: state) : Tot state
val loadState (rateInBytes: size_nat{rateInBytes <= 200}) (input: lbytes rateInBytes) (s: state) : Tot state
let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 103, "start_col": 0, "start_line": 95 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8)
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rateInBytes: Lib.IntTypes.size_nat{rateInBytes <= 200} -> input: Lib.ByteSequence.lbytes rateInBytes -> s: Spec.SHA3.state -> Spec.SHA3.state
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.ByteSequence.lbytes", "Spec.SHA3.state", "Lib.LoopCombinators.repeati", "Spec.SHA3.loadState_inner", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "Lib.Sequence.sub", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Sequence.update_sub", "Lib.IntTypes.uint_t", "FStar.Seq.Base.seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_imp", "Lib.Sequence.create", "Lib.IntTypes.u8" ]
[]
false
false
false
false
false
let loadState (rateInBytes: size_nat{rateInBytes <= 200}) (input: lbytes rateInBytes) (s: state) : Tot state =
let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s
false
LowParse.Low.Writers.fst
LowParse.Low.Writers.wcopy
val wcopy (#k #t: _) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (#rrel #rel: _) (sin: slice rrel rel) (pin_from pin_to: U32.t) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (sout_from0: U32.t) (h0: HS.mem { B.loc_disjoint (loc_slice_from_to sin pin_from pin_to) (loc_slice_from sout sout_from0) /\ valid_pos p h0 sin pin_from pin_to }) : Tot (w: writer s h0 sout sout_from0 {wvalue w == contents p h0 sin pin_from})
val wcopy (#k #t: _) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (#rrel #rel: _) (sin: slice rrel rel) (pin_from pin_to: U32.t) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (sout_from0: U32.t) (h0: HS.mem { B.loc_disjoint (loc_slice_from_to sin pin_from pin_to) (loc_slice_from sout sout_from0) /\ valid_pos p h0 sin pin_from pin_to }) : Tot (w: writer s h0 sout sout_from0 {wvalue w == contents p h0 sin pin_from})
let wcopy (#k: _) (#t: _) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (#rrel #rel: _) (sin: slice rrel rel) (pin_from pin_to: U32.t) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (sout_from0: U32.t) (h0: HS.mem { B.loc_disjoint (loc_slice_from_to sin pin_from pin_to) (loc_slice_from sout sout_from0) /\ valid_pos p h0 sin pin_from pin_to }) : Tot (w: writer s h0 sout sout_from0 { wvalue w == contents p h0 sin pin_from }) = Writer (Ghost.hide (contents p h0 sin pin_from)) (fun sout_from -> copy_weak_with_length p sin pin_from pin_to sout sout_from )
{ "file_name": "src/lowparse/LowParse.Low.Writers.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 875, "start_col": 0, "start_line": 856 }
module LowParse.Low.Writers include LowParse.Low.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module U32 = FStar.UInt32 module L = FStar.List.Tot inline_for_extraction noextract let fswriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ live_slice h sout /\ U32.v pout_from + serialized_length s x + space_beyond <= U32.v sout.len )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ valid_content_pos p h' sout pout_from x res )) inline_for_extraction noextract noeq type swriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | SWriter: (v: Ghost.erased t) -> (w: fswriter s h0 space_beyond sout pout_from0 (Ghost.reveal v)) -> swriter s h0 space_beyond sout pout_from0 let swvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#space_beyond: nat) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: swriter s h0 space_beyond sout pout_from0) : GTot t = Ghost.reveal w.v inline_for_extraction noextract let weaken_swriter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#space_beyond0: nat) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: swriter s h0 space_beyond0 sout pout_from0) (h1: HS.mem) (space_beyond1: nat) (pout_from1: U32.t) : Pure (w' : swriter s h1 space_beyond1 sout pout_from1 { swvalue w' == swvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1 /\ space_beyond0 <= space_beyond1)) (ensures (fun _ -> True)) = SWriter w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let swrite (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#space_beyond: nat) (w: swriter s h0 space_beyond sout pout_from0) : Tot (fswriter s h0 space_beyond sout pout_from0 (swvalue w)) = match w with | SWriter _ f -> f inline_for_extraction noextract let swriter_ifthenelse (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#space_beyond: nat) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (cond: bool) (wtrue: (squash (cond == true) -> Tot (swriter s h0 space_beyond sout pout_from0))) (wfalse: (squash (cond == false) -> Tot (swriter s h0 space_beyond sout pout_from0))) : Tot (x: swriter s h0 space_beyond sout pout_from0 { swvalue x == (if cond then swvalue (wtrue ()) else swvalue (wfalse ())) } ) = SWriter (if cond then SWriter?.v (wtrue ()) else SWriter?.v (wfalse ())) (fun pout_from -> if cond then swrite (wtrue ()) pout_from else swrite (wfalse ()) pout_from) inline_for_extraction noextract let swrite_leaf (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (w: leaf_writer_strong s) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot (y: swriter s h0 0 sout pout_from0 { swvalue y == x } ) = SWriter (Ghost.hide x) (fun pout_from -> w x sout pout_from) inline_for_extraction noextract let fwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ live_slice h sout /\ U32.v pout_from <= U32.v sout.len /\ U32.v sout.len < U32.v max_uint32 )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ ( if res = max_uint32 then U32.v pout_from + serialized_length s x > U32.v sout.len else valid_content_pos p h' sout pout_from x res ))) inline_for_extraction noextract noeq type writer (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | Writer: (v: Ghost.erased t) -> (w: fwriter s h0 sout pout_from0 (Ghost.reveal v)) -> writer s h0 sout pout_from0 let wvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) : GTot t = Ghost.reveal w.v inline_for_extraction noextract let weaken_writer (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) (h1: HS.mem) (pout_from1: U32.t) : Pure (w' : writer s h1 sout pout_from1 { wvalue w' == wvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1)) (ensures (fun _ -> True)) = Writer w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let write (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) : Tot (fwriter s h0 sout pout_from0 (wvalue w)) = match w with | Writer _ f -> f inline_for_extraction noextract let writer_ifthenelse (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (cond: bool) (wtrue: (squash (cond == true) -> Tot (writer s h0 sout pout_from0))) (wfalse: (squash (cond == false) -> Tot (writer s h0 sout pout_from0))) : Tot (x: writer s h0 sout pout_from0 { wvalue x == (if cond then wvalue (wtrue ()) else wvalue (wfalse ())) } ) = Writer (if cond then Writer?.v (wtrue ()) else Writer?.v (wfalse ())) (fun pout_from -> if cond then write (wtrue ()) pout_from else write (wfalse ()) pout_from) inline_for_extraction noextract let write_leaf_cs (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_low < 4294967296 } ) (w: leaf_writer_strong s) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot (y: writer s h0 sout pout_from0 { wvalue y == x } ) = Writer (Ghost.hide x) (fun pout_from -> if U32.uint_to_t k.parser_kind_low `U32.gt` (sout.len `U32.sub` pout_from) then max_uint32 else w x sout pout_from ) inline_for_extraction noextract let flwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: list t) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h sout /\ B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ U32.v pout_from <= U32.v sout.len /\ U32.v sout.len < U32.v max_uint32 )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ ( if res = max_uint32 then U32.v pout_from + serialized_list_length s x > U32.v sout.len else valid_list p h' sout pout_from res /\ contents_list p h' sout pout_from res == x ))) inline_for_extraction noeq noextract type lwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | LWriter: (v: Ghost.erased (list t)) -> (w: flwriter s h0 sout pout_from0 (Ghost.reveal v)) -> lwriter s h0 sout pout_from0 inline_for_extraction noextract let lwvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: lwriter s h0 sout pout_from0) : GTot (list t) = Ghost.reveal w.v inline_for_extraction noextract let weaken_lwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: lwriter s h0 sout pout_from0) (h1: HS.mem) (pout_from1: U32.t) : Pure (w' : lwriter s h1 sout pout_from1 { lwvalue w' == lwvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1)) (ensures (fun _ -> True)) = LWriter w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let lwrite (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: lwriter s h0 sout pout_from0) : Tot (flwriter s h0 sout pout_from0 (lwvalue w)) = match w with | LWriter _ f -> f inline_for_extraction noextract let lwriter_nil (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Tot (x: lwriter s h0 sout pout_from0 { lwvalue x == [] }) = LWriter (Ghost.hide []) (fun pout_from -> let h = HST.get () in valid_list_nil p h sout pout_from; pout_from ) inline_for_extraction noextract let lwriter_singleton (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) : Tot (x: lwriter s h0 sout pout_from0 { lwvalue x == [wvalue w] } ) = LWriter (Ghost.hide [wvalue w]) (fun pout_from -> let res = write w pout_from in if res `U32.lt` max_uint32 then begin let h = HST.get () in valid_list_nil p h sout res; valid_list_cons p h sout pout_from res end else begin [@inline_let] let f () : Lemma (ensures (let v = wvalue w in serialized_list_length s [v] == serialized_length s v)) = serialized_list_length_cons s (wvalue w) []; serialized_list_length_nil s in f () end; res ) inline_for_extraction noextract let lwriter_append (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w1 w2: lwriter s h0 sout pout_from0) : Tot (x: lwriter s h0 sout pout_from0 { lwvalue x == lwvalue w1 `List.Tot.append` lwvalue w2 } ) = LWriter (Ghost.hide (lwvalue w1 `List.Tot.append` lwvalue w2)) (fun pout_from -> let res1 = lwrite w1 pout_from in Classical.forall_intro_2 (serialized_list_length_append s); if res1 = max_uint32 then res1 else begin let res2 = lwrite w2 res1 in let h = HST.get () in valid_list_serialized_list_length s h sout pout_from res1; if res2 `U32.lt` (max_uint32) then begin valid_list_serialized_list_length s h sout res1 res2; valid_list_append p h sout pout_from res1 res2; valid_list_serialized_list_length s h sout pout_from res2 end; res2 end ) inline_for_extraction noextract let lwriter_ifthenelse (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (cond: bool) (wtrue: (squash (cond == true) -> Tot (lwriter s h0 sout pout_from0))) (wfalse: (squash (cond == false) -> Tot (lwriter s h0 sout pout_from0))) : Tot (x: lwriter s h0 sout pout_from0 { lwvalue x == (if cond then lwvalue (wtrue ()) else lwvalue (wfalse ())) } ) = LWriter (if cond then (wtrue ()).v else (wfalse ()).v) (fun pout_from -> if cond then lwrite (wtrue ()) pout_from else lwrite (wfalse ()) pout_from) inline_for_extraction noextract let lwriter_list_map (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (j1: jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong /\ k2.parser_kind_low > 0 } ) (f: t1 -> Tot t2) (#rrel #rel: _) (sin: slice rrel rel) (pin_from pin_to: U32.t) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t { B.loc_disjoint (loc_slice_from sout pout_from0) (loc_slice_from_to sin pin_from pin_to) /\ valid_list p1 h0 sin pin_from pin_to }) (f' : ( (pos: U32.t { U32.v pin_from <= U32.v pos /\ valid p1 h0 sin pos /\ U32.v pos + content_length p1 h0 sin pos <= U32.v pin_to }) -> Tot (y: writer s2 h0 sout pout_from0 { wvalue y == f (contents p1 h0 sin pos) }) )) : Tot (x: lwriter s2 h0 sout pout_from0 { lwvalue x == List.Tot.map f (contents_list p1 h0 sin pin_from pin_to) } ) = LWriter (Ghost.hide (List.Tot.map f (contents_list p1 h0 sin pin_from pin_to))) (fun pout_from -> assert (k1.parser_kind_subkind == Some ParserStrong); let h = HST.get () in list_map j1 s2 f h sin pin_from pin_to sout pout_from (fun pin_ pout_ -> valid_pos_frame_strong p1 h0 sin pin_ (get_valid_pos p1 h sin pin_) (loc_slice_from sout pout_from0) h; write (f' pin_) pout_ ) ) (* With options (other failures) *) inline_for_extraction noextract let fowriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: option t) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ live_slice h sout /\ U32.v pout_from <= U32.v sout.len /\ U32.v sout.len < U32.v max_uint32 - 1 )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ ( if res = max_uint32 then (Some? x ==> U32.v pout_from + serialized_length s (Some?.v x) > U32.v sout.len) else if res = max_uint32 `U32.sub` 1ul then None? x else Some? x /\ valid_content_pos p h' sout pout_from (Some?.v x) res ))) inline_for_extraction noextract noeq type owriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | OWriter: (v: Ghost.erased (option t)) -> (w: fowriter s h0 sout pout_from0 (Ghost.reveal v)) -> owriter s h0 sout pout_from0 let owvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: owriter s h0 sout pout_from0) : GTot (option t) = Ghost.reveal w.v inline_for_extraction noextract let weaken_owriter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: owriter s h0 sout pout_from0) (h1: HS.mem) (pout_from1: U32.t) : Pure (w' : owriter s h1 sout pout_from1 { owvalue w' == owvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1)) (ensures (fun _ -> True)) = OWriter w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let owrite (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: owriter s h0 sout pout_from0) : Tot (fowriter s h0 sout pout_from0 (owvalue w)) = match w with | OWriter _ f -> f inline_for_extraction noextract let owriter_ifthenelse (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (cond: bool) (wtrue: (squash (cond == true) -> Tot (owriter s h0 sout pout_from0))) (wfalse: (squash (cond == false) -> Tot (owriter s h0 sout pout_from0))) : Tot (x: owriter s h0 sout pout_from0 { owvalue x == (if cond then owvalue (wtrue ()) else owvalue (wfalse ())) } ) = OWriter (if cond then OWriter?.v (wtrue ()) else OWriter?.v (wfalse ())) (fun pout_from -> if cond then owrite (wtrue ()) pout_from else owrite (wfalse ()) pout_from) inline_for_extraction noextract let owrite_leaf_cs (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_low < 4294967296 } ) (w: leaf_writer_strong s) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: t) : Tot (y: owriter s h0 sout pout_from0 { owvalue y == Some x } ) = OWriter (Ghost.hide (Some x)) (fun pout_from -> if U32.uint_to_t k.parser_kind_low `U32.gt` (sout.len `U32.sub` pout_from) then max_uint32 else w x sout pout_from ) inline_for_extraction noextract let owriter_of_writer (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: writer s h0 sout pout_from0) : Tot (x: owriter s h0 sout pout_from0 { owvalue x == Some (wvalue w) }) = OWriter (Ghost.hide (Some (wvalue w))) (fun pout_from -> write w pout_from) inline_for_extraction noextract let folwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (x: option (list t)) : Tot Type = (pout_from: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h sout /\ B.modifies (loc_slice_from sout pout_from0) h0 h /\ U32.v pout_from0 <= U32.v pout_from /\ U32.v pout_from <= U32.v sout.len /\ U32.v sout.len < U32.v max_uint32 - 1 )) (ensures (fun h res h' -> B.modifies (loc_slice_from sout pout_from) h h' /\ ( if res = max_uint32 then (Some? x ==> U32.v pout_from + serialized_list_length s (Some?.v x) > U32.v sout.len) else if res = max_uint32 `U32.sub` 1ul then None? x else Some? x /\ valid_list p h' sout pout_from res /\ contents_list p h' sout pout_from res == (Some?.v x) ))) inline_for_extraction noeq noextract type olwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Type = | OLWriter: (v: Ghost.erased (option (list t))) -> (w: folwriter s h0 sout pout_from0 (Ghost.reveal v)) -> olwriter s h0 sout pout_from0 inline_for_extraction noextract let olwvalue (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: olwriter s h0 sout pout_from0) : GTot (option (list t)) = Ghost.reveal w.v inline_for_extraction noextract let weaken_olwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: olwriter s h0 sout pout_from0) (h1: HS.mem) (pout_from1: U32.t) : Pure (w' : olwriter s h1 sout pout_from1 { olwvalue w' == olwvalue w } ) (requires (B.modifies (loc_slice_from sout pout_from0) h0 h1 /\ U32.v pout_from0 <= U32.v pout_from1)) (ensures (fun _ -> True)) = OLWriter w.v (fun pout_from -> w.w pout_from) inline_for_extraction noextract let olwrite (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: olwriter s h0 sout pout_from0) : Tot (folwriter s h0 sout pout_from0 (olwvalue w)) = match w with | OLWriter _ f -> f inline_for_extraction noextract let olwriter_nil (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) : Tot (x: olwriter s h0 sout pout_from0 { olwvalue x == Some [] }) = OLWriter (Ghost.hide (Some [])) (fun pout_from -> let h = HST.get () in valid_list_nil p h sout pout_from; pout_from ) inline_for_extraction noextract let olwriter_singleton (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: owriter s h0 sout pout_from0) : Tot (x: olwriter s h0 sout pout_from0 { olwvalue x == (match owvalue w with None -> None | Some x -> Some [x]) }) = OLWriter (Ghost.hide (match owvalue w with None -> None | Some x -> Some [x])) (fun pout_from -> let res = owrite w pout_from in if res `U32.lt` (max_uint32 `U32.sub` 1ul) then begin let h = HST.get () in valid_list_nil p h sout res; valid_list_cons p h sout pout_from res end else begin [@inline_let] let f () : Lemma (requires (Some? (owvalue w))) (ensures (match owvalue w with | None -> False | Some v -> serialized_list_length s [v] == serialized_length s v)) = serialized_list_length_cons s (Some?.v (owvalue w)) []; serialized_list_length_nil s in Classical.move_requires f () end; res ) inline_for_extraction noextract let olwriter_append (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w1 w2: olwriter s h0 sout pout_from0) : Tot (x: olwriter s h0 sout pout_from0 { olwvalue x == (match olwvalue w1, olwvalue w2 with | Some l1, Some l2 -> Some (l1 `List.Tot.append` l2) | _ -> None) } ) = OLWriter (Ghost.hide (match olwvalue w1, olwvalue w2 with | Some l1, Some l2 -> Some (l1 `List.Tot.append` l2) | _ -> None)) (fun pout_from -> let res1 = olwrite w1 pout_from in Classical.forall_intro_2 (serialized_list_length_append s); if (max_uint32 `U32.sub` 1ul) `U32.lte` res1 then res1 else begin let res2 = olwrite w2 res1 in let h = HST.get () in valid_list_serialized_list_length s h sout pout_from res1; if res2 `U32.lt` (max_uint32 `U32.sub` 1ul) then begin valid_list_serialized_list_length s h sout res1 res2; valid_list_append p h sout pout_from res1 res2; valid_list_serialized_list_length s h sout pout_from res2 end; res2 end ) inline_for_extraction noextract let olwriter_ifthenelse (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (cond: bool) (wtrue: (squash (cond == true) -> Tot (olwriter s h0 sout pout_from0))) (wfalse: (squash (cond == false) -> Tot (olwriter s h0 sout pout_from0))) : Tot (x: olwriter s h0 sout pout_from0 { olwvalue x == (if cond then olwvalue (wtrue ()) else olwvalue (wfalse ())) } ) = OLWriter (if cond then (wtrue ()).v else (wfalse ()).v) (fun pout_from -> if cond then olwrite (wtrue ()) pout_from else olwrite (wfalse ()) pout_from) inline_for_extraction noextract let olwriter_of_lwriter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p { k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_low > 0 } ) (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (w: lwriter s h0 sout pout_from0) : Tot (olwriter s h0 sout pout_from0) = OLWriter (Ghost.hide (Some (lwvalue w))) (fun pout_from -> lwrite w pout_from) inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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 { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> sin: LowParse.Slice.slice rrel rel -> pin_from: FStar.UInt32.t -> pin_to: FStar.UInt32.t -> sout: LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte )) (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte)) -> sout_from0: FStar.UInt32.t -> h0: FStar.Monotonic.HyperStack.mem { LowStar.Monotonic.Buffer.loc_disjoint (LowParse.Slice.loc_slice_from_to sin pin_from pin_to) (LowParse.Slice.loc_slice_from sout sout_from0) /\ LowParse.Low.Base.Spec.valid_pos p h0 sin pin_from pin_to } -> w: LowParse.Low.Writers.writer s h0 sout sout_from0 {LowParse.Low.Writers.wvalue w == LowParse.Low.Base.Spec.contents p h0 sin pin_from}
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Slice.srel_of_buffer_srel", "LowStar.Buffer.trivial_preorder", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Monotonic.Buffer.loc_disjoint", "LowParse.Slice.loc_slice_from_to", "LowParse.Slice.loc_slice_from", "LowParse.Low.Base.Spec.valid_pos", "LowParse.Low.Writers.Writer", "FStar.Ghost.hide", "LowParse.Low.Base.Spec.contents", "LowParse.Low.Base.copy_weak_with_length", "LowParse.Low.Writers.writer", "LowParse.Low.Writers.wvalue" ]
[]
false
false
false
false
false
let wcopy (#k #t: _) (#p: parser k t) (s: serializer p {k.parser_kind_subkind == Some ParserStrong}) (#rrel #rel: _) (sin: slice rrel rel) (pin_from pin_to: U32.t) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (sout_from0: U32.t) (h0: HS.mem { B.loc_disjoint (loc_slice_from_to sin pin_from pin_to) (loc_slice_from sout sout_from0) /\ valid_pos p h0 sin pin_from pin_to }) : Tot (w: writer s h0 sout sout_from0 {wvalue w == contents p h0 sin pin_from}) =
Writer (Ghost.hide (contents p h0 sin pin_from)) (fun sout_from -> copy_weak_with_length p sin pin_from pin_to sout sout_from)
false
Spec.SHA3.fst
Spec.SHA3.absorb_last
val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state
val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state
let absorb_last delimitedSuffix rateInBytes rem input s = let lastBlock = create rateInBytes (u8 0) in let lastBlock = update_sub lastBlock 0 rem input in let lastBlock = lastBlock.[rem] <- byte_to_uint8 delimitedSuffix in let s = loadState rateInBytes lastBlock s in let s = if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (rem = rateInBytes - 1) then state_permute s else s in absorb_next s rateInBytes
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 136, "start_col": 0, "start_line": 127 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8) let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) = update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j]) let storeState (rateInBytes:size_nat{rateInBytes <= 200}) (s:state) : Tot (lbytes rateInBytes) = let block = create 200 (u8 0) in let block = repeati 25 (storeState_inner s) block in sub block 0 rateInBytes let absorb_next (s:state) (rateInBytes:size_nat{rateInBytes > 0 /\ rateInBytes <= 200}) : Tot state = let nextBlock = create rateInBytes (u8 0) in let nextBlock = nextBlock.[rateInBytes - 1] <- u8 0x80 in let s = loadState rateInBytes nextBlock s in state_permute s val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
delimitedSuffix: Lib.IntTypes.byte_t -> rateInBytes: Lib.IntTypes.size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem: Lib.IntTypes.size_nat{rem < rateInBytes} -> input: Lib.ByteSequence.lbytes rem -> s: Spec.SHA3.state -> Spec.SHA3.state
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.byte_t", "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Lib.ByteSequence.lbytes", "Spec.SHA3.state", "Spec.SHA3.absorb_next", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_AmpAmp", "Prims.op_Negation", "Lib.IntTypes.op_Equals_Dot", "Lib.IntTypes.U8", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.PUB", "Lib.IntTypes.byte", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Spec.SHA3.state_permute", "Prims.bool", "Spec.SHA3.loadState", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Lib.IntTypes.byte_to_uint8", "Lib.Sequence.index", "Prims.l_Forall", "Prims.nat", "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.Sequence.sub", "Prims.op_Addition", "Lib.Sequence.update_sub", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Lib.Sequence.create", "Lib.IntTypes.u8" ]
[]
false
false
false
false
false
let absorb_last delimitedSuffix rateInBytes rem input s =
let lastBlock = create rateInBytes (u8 0) in let lastBlock = update_sub lastBlock 0 rem input in let lastBlock = lastBlock.[ rem ] <- byte_to_uint8 delimitedSuffix in let s = loadState rateInBytes lastBlock s in let s = if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (rem = rateInBytes - 1) then state_permute s else s in absorb_next s rateInBytes
false
Spec.SHA3.fst
Spec.SHA3.loadState_inner
val loadState_inner (block: lbytes 200) (j: size_nat{j < 25}) (s: state) : Tot state
val loadState_inner (block: lbytes 200) (j: size_nat{j < 25}) (s: state) : Tot state
let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8)
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 93, "start_col": 0, "start_line": 92 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
block: Lib.ByteSequence.lbytes 200 -> j: Lib.IntTypes.size_nat{j < 25} -> s: Spec.SHA3.state -> Spec.SHA3.state
Prims.Tot
[ "total" ]
[]
[ "Lib.ByteSequence.lbytes", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThan", "Spec.SHA3.state", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.uint64", "Lib.IntTypes.op_Hat_Dot", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Sequence.op_String_Access", "Lib.ByteSequence.uint_from_bytes_le", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "FStar.Mul.op_Star" ]
[]
false
false
false
false
false
let loadState_inner (block: lbytes 200) (j: size_nat{j < 25}) (s: state) : Tot state =
s.[ j ] <- s.[ j ] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8)
false
Spec.SHA3.fst
Spec.SHA3.sha3_256
val sha3_256 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 32
val sha3_256 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 32
let sha3_256 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 32 = keccak 1088 512 inputByteLen input (byte 0x06) 32
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 222, "start_col": 0, "start_line": 221 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8) let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) = update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j]) let storeState (rateInBytes:size_nat{rateInBytes <= 200}) (s:state) : Tot (lbytes rateInBytes) = let block = create 200 (u8 0) in let block = repeati 25 (storeState_inner s) block in sub block 0 rateInBytes let absorb_next (s:state) (rateInBytes:size_nat{rateInBytes > 0 /\ rateInBytes <= 200}) : Tot state = let nextBlock = create rateInBytes (u8 0) in let nextBlock = nextBlock.[rateInBytes - 1] <- u8 0x80 in let s = loadState rateInBytes nextBlock s in state_permute s val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state let absorb_last delimitedSuffix rateInBytes rem input s = let lastBlock = create rateInBytes (u8 0) in let lastBlock = update_sub lastBlock 0 rem input in let lastBlock = lastBlock.[rem] <- byte_to_uint8 delimitedSuffix in let s = loadState rateInBytes lastBlock s in let s = if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (rem = rateInBytes - 1) then state_permute s else s in absorb_next s rateInBytes let absorb_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (block:lbytes rateInBytes) (s:state) : Tot state = let s = loadState rateInBytes block s in state_permute s let absorb (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (delimitedSuffix:byte_t) : Tot state = repeat_blocks rateInBytes input (absorb_inner rateInBytes) (absorb_last delimitedSuffix rateInBytes) s let squeeze_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat) (i:size_nat{i < outputByteLen / rateInBytes}) (s:state) : Tot (state & lbytes rateInBytes) = let block = storeState rateInBytes s in let s = state_permute s in s, block let squeeze (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat): Tot (lbytes outputByteLen) = let outBlocks = outputByteLen / rateInBytes in let a (i:nat{i <= outBlocks}) = state in let s, output = generate_blocks rateInBytes outBlocks outBlocks a (squeeze_inner rateInBytes outputByteLen) s in let remOut = outputByteLen % rateInBytes in let block = storeState remOut s in (to_lseq output) @| block val keccak: rate:size_nat{rate % 8 == 0 /\ rate / 8 > 0 /\ rate <= 1600} -> capacity:size_nat{capacity + rate == 1600} -> inputByteLen:nat -> input:bytes{length input == inputByteLen} -> delimitedSuffix:byte_t -> outputByteLen:size_nat -> Tot (lbytes outputByteLen) let keccak rate capacity inputByteLen input delimitedSuffix outputByteLen = let rateInBytes = rate / 8 in let s = create 25 (u64 0) in let s = absorb s rateInBytes inputByteLen input delimitedSuffix in squeeze s rateInBytes outputByteLen let shake128 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1344 256 inputByteLen input (byte 0x1F) outputByteLen let shake256 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1088 512 inputByteLen input (byte 0x1F) outputByteLen let sha3_224 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 28 = keccak 1152 448 inputByteLen input (byte 0x06) 28
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
inputByteLen: Prims.nat -> input: Lib.ByteSequence.bytes{Lib.Sequence.length input == inputByteLen} -> Lib.ByteSequence.lbytes 32
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Lib.ByteSequence.bytes", "Prims.eq2", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SHA3.keccak", "Lib.IntTypes.byte", "Lib.ByteSequence.lbytes" ]
[]
false
false
false
false
false
let sha3_256 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 32 =
keccak 1088 512 inputByteLen input (byte 0x06) 32
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.add
val add: BN.bn_add_eq_len_st t_limbs n_limbs
val add: BN.bn_add_eq_len_st t_limbs n_limbs
let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 15, "start_col": 0, "start_line": 14 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.bn_add_eq_len_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_add_eq_len", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.bn_add_eq_len_st" ]
[]
false
false
false
true
false
let add:BN.bn_add_eq_len_st t_limbs n_limbs =
BN.bn_add_eq_len n_limbs
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.sub
val sub: BN.bn_sub_eq_len_st t_limbs n_limbs
val sub: BN.bn_sub_eq_len_st t_limbs n_limbs
let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 18, "start_col": 0, "start_line": 17 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.bn_sub_eq_len_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_sub_eq_len", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.bn_sub_eq_len_st" ]
[]
false
false
false
true
false
let sub:BN.bn_sub_eq_len_st t_limbs n_limbs =
BN.bn_sub_eq_len n_limbs
false
Spec.SHA3.fst
Spec.SHA3.sha3_224
val sha3_224 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 28
val sha3_224 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 28
let sha3_224 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 28 = keccak 1152 448 inputByteLen input (byte 0x06) 28
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 219, "start_col": 0, "start_line": 218 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8) let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) = update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j]) let storeState (rateInBytes:size_nat{rateInBytes <= 200}) (s:state) : Tot (lbytes rateInBytes) = let block = create 200 (u8 0) in let block = repeati 25 (storeState_inner s) block in sub block 0 rateInBytes let absorb_next (s:state) (rateInBytes:size_nat{rateInBytes > 0 /\ rateInBytes <= 200}) : Tot state = let nextBlock = create rateInBytes (u8 0) in let nextBlock = nextBlock.[rateInBytes - 1] <- u8 0x80 in let s = loadState rateInBytes nextBlock s in state_permute s val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state let absorb_last delimitedSuffix rateInBytes rem input s = let lastBlock = create rateInBytes (u8 0) in let lastBlock = update_sub lastBlock 0 rem input in let lastBlock = lastBlock.[rem] <- byte_to_uint8 delimitedSuffix in let s = loadState rateInBytes lastBlock s in let s = if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (rem = rateInBytes - 1) then state_permute s else s in absorb_next s rateInBytes let absorb_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (block:lbytes rateInBytes) (s:state) : Tot state = let s = loadState rateInBytes block s in state_permute s let absorb (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (delimitedSuffix:byte_t) : Tot state = repeat_blocks rateInBytes input (absorb_inner rateInBytes) (absorb_last delimitedSuffix rateInBytes) s let squeeze_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat) (i:size_nat{i < outputByteLen / rateInBytes}) (s:state) : Tot (state & lbytes rateInBytes) = let block = storeState rateInBytes s in let s = state_permute s in s, block let squeeze (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat): Tot (lbytes outputByteLen) = let outBlocks = outputByteLen / rateInBytes in let a (i:nat{i <= outBlocks}) = state in let s, output = generate_blocks rateInBytes outBlocks outBlocks a (squeeze_inner rateInBytes outputByteLen) s in let remOut = outputByteLen % rateInBytes in let block = storeState remOut s in (to_lseq output) @| block val keccak: rate:size_nat{rate % 8 == 0 /\ rate / 8 > 0 /\ rate <= 1600} -> capacity:size_nat{capacity + rate == 1600} -> inputByteLen:nat -> input:bytes{length input == inputByteLen} -> delimitedSuffix:byte_t -> outputByteLen:size_nat -> Tot (lbytes outputByteLen) let keccak rate capacity inputByteLen input delimitedSuffix outputByteLen = let rateInBytes = rate / 8 in let s = create 25 (u64 0) in let s = absorb s rateInBytes inputByteLen input delimitedSuffix in squeeze s rateInBytes outputByteLen let shake128 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1344 256 inputByteLen input (byte 0x1F) outputByteLen let shake256 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1088 512 inputByteLen input (byte 0x1F) outputByteLen
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
inputByteLen: Prims.nat -> input: Lib.ByteSequence.bytes{Lib.Sequence.length input == inputByteLen} -> Lib.ByteSequence.lbytes 28
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Lib.ByteSequence.bytes", "Prims.eq2", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SHA3.keccak", "Lib.IntTypes.byte", "Lib.ByteSequence.lbytes" ]
[]
false
false
false
false
false
let sha3_224 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 28 =
keccak 1152 448 inputByteLen input (byte 0x06) 28
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.precompr2
val precompr2:BM.bn_precomp_r2_mod_n_st t_limbs n_limbs
val precompr2:BM.bn_precomp_r2_mod_n_st t_limbs n_limbs
let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 50, "start_col": 0, "start_line": 49 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Montgomery.bn_precomp_r2_mod_n_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.bn_inst" ]
[]
false
false
false
true
false
let precompr2:BM.bn_precomp_r2_mod_n_st t_limbs n_limbs =
BM.bn_precomp_r2_mod_n bn_inst
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mont_check
val mont_check:BM.bn_check_modulus_st t_limbs n_limbs
val mont_check:BM.bn_check_modulus_st t_limbs n_limbs
let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 46, "start_col": 0, "start_line": 45 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Montgomery.bn_check_modulus_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Montgomery.bn_check_modulus", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs" ]
[]
false
false
false
true
false
let mont_check:BM.bn_check_modulus_st t_limbs n_limbs =
BM.bn_check_modulus
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.bn_inst
[@@ FStar.Tactics.Typeclasses.tcinstance] val bn_inst:BN.bn t_limbs
[@@ FStar.Tactics.Typeclasses.tcinstance] val bn_inst:BN.bn t_limbs
instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr }
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 1, "end_line": 42, "start_col": 0, "start_line": 34 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.bn Hacl.Bignum256_32.t_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Mkbn", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum256_32.add", "Hacl.Bignum256_32.sub", "Hacl.Bignum256_32.add_mod", "Hacl.Bignum256_32.sub_mod", "Hacl.Bignum256_32.mul", "Hacl.Bignum256_32.sqr" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let bn_inst:BN.bn t_limbs =
{ BN.len = n_limbs; BN.add = add; BN.sub = sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul = mul; BN.sqr = sqr }
false
Spec.SHA3.fst
Spec.SHA3.sha3_512
val sha3_512 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 64
val sha3_512 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 64
let sha3_512 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 64 = keccak 576 1024 inputByteLen input (byte 0x06) 64
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 228, "start_col": 0, "start_line": 227 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8) let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) = update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j]) let storeState (rateInBytes:size_nat{rateInBytes <= 200}) (s:state) : Tot (lbytes rateInBytes) = let block = create 200 (u8 0) in let block = repeati 25 (storeState_inner s) block in sub block 0 rateInBytes let absorb_next (s:state) (rateInBytes:size_nat{rateInBytes > 0 /\ rateInBytes <= 200}) : Tot state = let nextBlock = create rateInBytes (u8 0) in let nextBlock = nextBlock.[rateInBytes - 1] <- u8 0x80 in let s = loadState rateInBytes nextBlock s in state_permute s val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state let absorb_last delimitedSuffix rateInBytes rem input s = let lastBlock = create rateInBytes (u8 0) in let lastBlock = update_sub lastBlock 0 rem input in let lastBlock = lastBlock.[rem] <- byte_to_uint8 delimitedSuffix in let s = loadState rateInBytes lastBlock s in let s = if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (rem = rateInBytes - 1) then state_permute s else s in absorb_next s rateInBytes let absorb_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (block:lbytes rateInBytes) (s:state) : Tot state = let s = loadState rateInBytes block s in state_permute s let absorb (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (delimitedSuffix:byte_t) : Tot state = repeat_blocks rateInBytes input (absorb_inner rateInBytes) (absorb_last delimitedSuffix rateInBytes) s let squeeze_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat) (i:size_nat{i < outputByteLen / rateInBytes}) (s:state) : Tot (state & lbytes rateInBytes) = let block = storeState rateInBytes s in let s = state_permute s in s, block let squeeze (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat): Tot (lbytes outputByteLen) = let outBlocks = outputByteLen / rateInBytes in let a (i:nat{i <= outBlocks}) = state in let s, output = generate_blocks rateInBytes outBlocks outBlocks a (squeeze_inner rateInBytes outputByteLen) s in let remOut = outputByteLen % rateInBytes in let block = storeState remOut s in (to_lseq output) @| block val keccak: rate:size_nat{rate % 8 == 0 /\ rate / 8 > 0 /\ rate <= 1600} -> capacity:size_nat{capacity + rate == 1600} -> inputByteLen:nat -> input:bytes{length input == inputByteLen} -> delimitedSuffix:byte_t -> outputByteLen:size_nat -> Tot (lbytes outputByteLen) let keccak rate capacity inputByteLen input delimitedSuffix outputByteLen = let rateInBytes = rate / 8 in let s = create 25 (u64 0) in let s = absorb s rateInBytes inputByteLen input delimitedSuffix in squeeze s rateInBytes outputByteLen let shake128 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1344 256 inputByteLen input (byte 0x1F) outputByteLen let shake256 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1088 512 inputByteLen input (byte 0x1F) outputByteLen let sha3_224 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 28 = keccak 1152 448 inputByteLen input (byte 0x06) 28 let sha3_256 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 32 = keccak 1088 512 inputByteLen input (byte 0x06) 32 let sha3_384 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 48 = keccak 832 768 inputByteLen input (byte 0x06) 48
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
inputByteLen: Prims.nat -> input: Lib.ByteSequence.bytes{Lib.Sequence.length input == inputByteLen} -> Lib.ByteSequence.lbytes 64
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Lib.ByteSequence.bytes", "Prims.eq2", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SHA3.keccak", "Lib.IntTypes.byte", "Lib.ByteSequence.lbytes" ]
[]
false
false
false
false
false
let sha3_512 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 64 =
keccak 576 1024 inputByteLen input (byte 0x06) 64
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.almost_mont_inst
[@@ FStar.Tactics.Typeclasses.tcinstance] val almost_mont_inst:AM.almost_mont t_limbs
[@@ FStar.Tactics.Typeclasses.tcinstance] val almost_mont_inst:AM.almost_mont t_limbs
instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; }
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 1, "end_line": 106, "start_col": 0, "start_line": 97 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.AlmostMontgomery.almost_mont Hacl.Bignum256_32.t_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.AlmostMontgomery.Mkalmost_mont", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.bn_inst", "Hacl.Bignum256_32.mont_check", "Hacl.Bignum256_32.precompr2", "Hacl.Bignum256_32.areduction", "Hacl.Bignum256_32.to", "Hacl.Bignum256_32.from", "Hacl.Bignum256_32.amont_mul", "Hacl.Bignum256_32.amont_sqr" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let almost_mont_inst:AM.almost_mont t_limbs =
{ AM.bn = bn_inst; AM.mont_check = mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to = to; AM.from = from; AM.mul = amont_mul; AM.sqr = amont_sqr }
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.from
val from:BM.bn_from_mont_st t_limbs n_limbs
val from:BM.bn_from_mont_st t_limbs n_limbs
let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 62, "start_col": 0, "start_line": 61 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Montgomery.bn_from_mont_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Montgomery.bn_from_mont", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.bn_inst", "Hacl.Bignum256_32.reduction" ]
[]
false
false
false
true
false
let from:BM.bn_from_mont_st t_limbs n_limbs =
BM.bn_from_mont bn_inst reduction
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.to
val to:BM.bn_to_mont_st t_limbs n_limbs
val to:BM.bn_to_mont_st t_limbs n_limbs
let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 58, "start_col": 0, "start_line": 57 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Montgomery.bn_to_mont_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Montgomery.bn_to_mont", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.bn_inst", "Hacl.Bignum256_32.reduction" ]
[]
false
false
false
true
false
let to:BM.bn_to_mont_st t_limbs n_limbs =
BM.bn_to_mont bn_inst reduction
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.bn_slow_precomp
val bn_slow_precomp:BR.bn_mod_slow_precomp_st t_limbs n_limbs
val bn_slow_precomp:BR.bn_mod_slow_precomp_st t_limbs n_limbs
let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 110, "start_col": 0, "start_line": 109 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.ModReduction.bn_mod_slow_precomp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.ModReduction.bn_mod_slow_precomp", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.almost_mont_inst" ]
[]
false
false
false
true
false
let bn_slow_precomp:BR.bn_mod_slow_precomp_st t_limbs n_limbs =
BR.bn_mod_slow_precomp almost_mont_inst
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.amont_mul
val amont_mul:AM.bn_almost_mont_mul_st t_limbs n_limbs
val amont_mul:AM.bn_almost_mont_mul_st t_limbs n_limbs
let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 90, "start_col": 0, "start_line": 89 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.AlmostMontgomery.bn_almost_mont_mul_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.AlmostMontgomery.bn_almost_mont_mul", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.bn_inst", "Hacl.Bignum256_32.areduction" ]
[]
false
false
false
true
false
let amont_mul:AM.bn_almost_mont_mul_st t_limbs n_limbs =
AM.bn_almost_mont_mul bn_inst areduction
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.exp_check
val exp_check:BE.bn_check_mod_exp_st t_limbs n_limbs
val exp_check:BE.bn_check_mod_exp_st t_limbs n_limbs
let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 116, "start_col": 0, "start_line": 115 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Exponentiation.bn_check_mod_exp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Exponentiation.bn_check_mod_exp", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs" ]
[]
false
false
false
true
false
let exp_check:BE.bn_check_mod_exp_st t_limbs n_limbs =
BE.bn_check_mod_exp n_limbs
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.exp_vartime
val exp_vartime:BE.bn_mod_exp_st t_limbs n_limbs
val exp_vartime:BE.bn_mod_exp_st t_limbs n_limbs
let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 56, "end_line": 132, "start_col": 0, "start_line": 131 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Exponentiation.bn_mod_exp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Exponentiation.mk_bn_mod_exp", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum256_32.precompr2", "Hacl.Bignum256_32.exp_vartime_precomp" ]
[]
false
false
false
true
false
let exp_vartime:BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
false
Spec.SHA3.fst
Spec.SHA3.sha3_384
val sha3_384 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 48
val sha3_384 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 48
let sha3_384 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 48 = keccak 832 768 inputByteLen input (byte 0x06) 48
{ "file_name": "specs/Spec.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 225, "start_col": 0, "start_line": 224 }
module Spec.SHA3 open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" unfold type state = lseq uint64 25 unfold type index = n:size_nat{n < 5} let get (s:state) (x:index) (y:index) : Tot uint64 = s.[x + 5 * y] let set (s:state) (x:index) (y:index) (v:uint64) : Tot state = s.[x + 5 * y] <- v let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) : Tot uint64 = rotate_left a b let state_theta_inner_C (s:state) (i:size_nat{i < 5}) (_C:lseq uint64 5) : Tot (lseq uint64 5) = _C.[i] <- get s i 0 ^. get s i 1 ^. get s i 2 ^. get s i 3 ^. get s i 4 let state_theta0 (s:state) (_C:lseq uint64 5) = repeati 5 (state_theta_inner_C s) _C let state_theta_inner_s_inner (x:index) (_D:uint64) (y:index) (s:state) : Tot state = set s x y (get s x y ^. _D) let state_theta_inner_s (_C:lseq uint64 5) (x:index) (s:state) : Tot state = let _D = _C.[(x + 4) % 5] ^. (rotl _C.[(x + 1) % 5] (size 1)) in repeati 5 (state_theta_inner_s_inner x _D) s let state_theta1 (s:state) (_C:lseq uint64 5) : Tot state = repeati 5 (state_theta_inner_s _C) s let state_theta (s:state) : Tot state = let _C = create 5 (u64 0) in let _C = state_theta0 s _C in state_theta1 s _C let state_pi_rho_inner (i:size_nat{i < 24}) (current, s) : (uint64 & state) = let r = keccak_rotc.[i] in let _Y = v keccak_piln.[i] in let temp = s.[_Y] in let s = s.[_Y] <- rotl current r in let current = temp in current, s val state_pi_rho_s: i:size_nat{i <= 24} -> Type0 let state_pi_rho_s i = uint64 & state let state_pi_rho (s_theta:state) : Tot state = let current = get s_theta 1 0 in let _, s_pi_rho = repeat_gen 24 state_pi_rho_s state_pi_rho_inner (current, s_theta) in s_pi_rho let state_chi_inner0 (s_pi_rho:state) (y:index) (x:index) (s:state) : Tot state = set s x y (get s_pi_rho x y ^. ((lognot (get s_pi_rho ((x + 1) % 5) y)) &. get s_pi_rho ((x + 2) % 5) y)) let state_chi_inner1 (s_pi_rho:state) (y:index) (s:state) : Tot state = repeati 5 (state_chi_inner0 s_pi_rho y) s let state_chi (s_pi_rho:state) : Tot state = repeati 5 (state_chi_inner1 s_pi_rho) s_pi_rho let state_iota (s:state) (round:size_nat{round < 24}) : Tot state = set s 0 0 (get s 0 0 ^. secret keccak_rndc.[round]) let state_permute1 (round:size_nat{round < 24}) (s:state) : Tot state = let s_theta = state_theta s in let s_pi_rho = state_pi_rho s_theta in let s_chi = state_chi s_pi_rho in let s_iota = state_iota s_chi round in s_iota let state_permute (s:state) : Tot state = repeati 24 state_permute1 s let loadState_inner (block:lbytes 200) (j:size_nat{j < 25}) (s:state) : Tot state = s.[j] <- s.[j] ^. uint_from_bytes_le #U64 (sub block (j * 8) 8) let loadState (rateInBytes:size_nat{rateInBytes <= 200}) (input:lbytes rateInBytes) (s:state) : Tot state = let block = create 200 (u8 0) in let block = update_sub block 0 rateInBytes input in repeati 25 (loadState_inner block) s let storeState_inner (s:state) (j:size_nat{j < 25}) (block:lbytes 200) : Tot (lbytes 200) = update_sub block (j * 8) 8 (uint_to_bytes_le #U64 s.[j]) let storeState (rateInBytes:size_nat{rateInBytes <= 200}) (s:state) : Tot (lbytes rateInBytes) = let block = create 200 (u8 0) in let block = repeati 25 (storeState_inner s) block in sub block 0 rateInBytes let absorb_next (s:state) (rateInBytes:size_nat{rateInBytes > 0 /\ rateInBytes <= 200}) : Tot state = let nextBlock = create rateInBytes (u8 0) in let nextBlock = nextBlock.[rateInBytes - 1] <- u8 0x80 in let s = loadState rateInBytes nextBlock s in state_permute s val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200} -> rem:size_nat{rem < rateInBytes} -> input:lbytes rem -> s:state -> Tot state let absorb_last delimitedSuffix rateInBytes rem input s = let lastBlock = create rateInBytes (u8 0) in let lastBlock = update_sub lastBlock 0 rem input in let lastBlock = lastBlock.[rem] <- byte_to_uint8 delimitedSuffix in let s = loadState rateInBytes lastBlock s in let s = if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (rem = rateInBytes - 1) then state_permute s else s in absorb_next s rateInBytes let absorb_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (block:lbytes rateInBytes) (s:state) : Tot state = let s = loadState rateInBytes block s in state_permute s let absorb (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (delimitedSuffix:byte_t) : Tot state = repeat_blocks rateInBytes input (absorb_inner rateInBytes) (absorb_last delimitedSuffix rateInBytes) s let squeeze_inner (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat) (i:size_nat{i < outputByteLen / rateInBytes}) (s:state) : Tot (state & lbytes rateInBytes) = let block = storeState rateInBytes s in let s = state_permute s in s, block let squeeze (s:state) (rateInBytes:size_nat{0 < rateInBytes /\ rateInBytes <= 200}) (outputByteLen:size_nat): Tot (lbytes outputByteLen) = let outBlocks = outputByteLen / rateInBytes in let a (i:nat{i <= outBlocks}) = state in let s, output = generate_blocks rateInBytes outBlocks outBlocks a (squeeze_inner rateInBytes outputByteLen) s in let remOut = outputByteLen % rateInBytes in let block = storeState remOut s in (to_lseq output) @| block val keccak: rate:size_nat{rate % 8 == 0 /\ rate / 8 > 0 /\ rate <= 1600} -> capacity:size_nat{capacity + rate == 1600} -> inputByteLen:nat -> input:bytes{length input == inputByteLen} -> delimitedSuffix:byte_t -> outputByteLen:size_nat -> Tot (lbytes outputByteLen) let keccak rate capacity inputByteLen input delimitedSuffix outputByteLen = let rateInBytes = rate / 8 in let s = create 25 (u64 0) in let s = absorb s rateInBytes inputByteLen input delimitedSuffix in squeeze s rateInBytes outputByteLen let shake128 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1344 256 inputByteLen input (byte 0x1F) outputByteLen let shake256 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) (outputByteLen:size_nat) : Tot (lbytes outputByteLen) = keccak 1088 512 inputByteLen input (byte 0x1F) outputByteLen let sha3_224 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 28 = keccak 1152 448 inputByteLen input (byte 0x06) 28 let sha3_256 (inputByteLen:nat) (input:bytes{length input == inputByteLen}) : lbytes 32 = keccak 1088 512 inputByteLen input (byte 0x06) 32
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "prims.fst.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" ], "interface_file": false, "source_file": "Spec.SHA3.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
inputByteLen: Prims.nat -> input: Lib.ByteSequence.bytes{Lib.Sequence.length input == inputByteLen} -> Lib.ByteSequence.lbytes 48
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Lib.ByteSequence.bytes", "Prims.eq2", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.SHA3.keccak", "Lib.IntTypes.byte", "Lib.ByteSequence.lbytes" ]
[]
false
false
false
false
false
let sha3_384 (inputByteLen: nat) (input: bytes{length input == inputByteLen}) : lbytes 48 =
keccak 832 768 inputByteLen input (byte 0x06) 48
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mod_exp_consttime
val mod_exp_consttime: BS.bn_mod_exp_safe_st t_limbs n_limbs
val mod_exp_consttime: BS.bn_mod_exp_safe_st t_limbs n_limbs
let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 77, "end_line": 140, "start_col": 0, "start_line": 140 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.bn_mod_exp_safe_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.SafeAPI.mk_bn_mod_exp_safe", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum256_32.exp_check", "Hacl.Bignum256_32.exp_consttime" ]
[]
false
false
false
true
false
let mod_exp_consttime =
BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.exp_consttime
val exp_consttime:BE.bn_mod_exp_st t_limbs n_limbs
val exp_consttime:BE.bn_mod_exp_st t_limbs n_limbs
let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 136, "start_col": 0, "start_line": 135 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Exponentiation.bn_mod_exp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Exponentiation.mk_bn_mod_exp", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum256_32.precompr2", "Hacl.Bignum256_32.exp_consttime_precomp" ]
[]
false
false
false
true
false
let exp_consttime:BE.bn_mod_exp_st t_limbs n_limbs =
BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mod_exp_vartime
val mod_exp_vartime: BS.bn_mod_exp_safe_st t_limbs n_limbs
val mod_exp_vartime: BS.bn_mod_exp_safe_st t_limbs n_limbs
let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 138, "start_col": 0, "start_line": 138 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.bn_mod_exp_safe_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.SafeAPI.mk_bn_mod_exp_safe", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum256_32.exp_check", "Hacl.Bignum256_32.exp_vartime" ]
[]
false
false
false
true
false
let mod_exp_vartime =
BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mont_ctx_init
val mont_ctx_init: MA.bn_field_init_st t_limbs n_limbs
val mont_ctx_init: MA.bn_field_init_st t_limbs n_limbs
let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 145, "start_col": 0, "start_line": 144 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.MontArithmetic.bn_field_init_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.MontArithmetic.bn_field_init", "Hacl.Bignum256_32.precompr2", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx" ]
[]
false
false
false
true
false
let mont_ctx_init r n =
MA.bn_field_init n_limbs precompr2 r n
false
Steel.ST.Array.Util.fst
Steel.ST.Array.Util.forall2_cond
val forall2_cond: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: G.erased (Seq.seq a) -> s1: G.erased (Seq.seq b) -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())
val forall2_cond: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: G.erased (Seq.seq a) -> s1: G.erased (Seq.seq b) -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())
let forall2_cond (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:G.erased (Seq.seq a)) (s1:G.erased (Seq.seq b)) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt0 = A.read a0 i in let elt1 = A.read a1 i in return (p elt0 elt1) in intro_pure (forall2_pure_inv n p s0 s1 () i); intro_pure (forall2_pure_inv_b n p s0 s1 () i res); intro_exists i (forall2_pred n a0 a1 p r p0 p1 s0 s1 () res); return res
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 364, "start_col": 0, "start_line": 332 }
(* Copyright 2021 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b) inline_for_extraction let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res inline_for_extraction let forall_body (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) = fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; //atomic increment? let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall_pure_inv n p s () (US.add i 1sz)); intro_pure (forall_pure_inv_b n p s () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall_pred n arr p r perm s () ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz)))) (forall_inv n arr p r perm s ()) let for_all #a #perm #s n arr p = A.pts_to_length arr s; let b = n = 0sz in if b then return true else begin //This could be stack allocated let r = R.alloc 0sz in intro_pure (forall_pure_inv n p s () 0sz); intro_pure (forall_pure_inv_b n p s () 0sz (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists 0sz (forall_pred n arr p r perm s () (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists (0sz `US.lt` n && p (Seq.index s (US.v 0sz))) (forall_inv n arr p r perm s ()); Loops.while_loop (forall_inv n arr p r perm s ()) (forall_cond n arr p r perm s ()) (forall_body n arr p r perm s ()); let _ = elim_exists () in let _ = elim_pure _ in let _ = elim_pure _ in let i = R.read r in //This free would go away if we had stack allocations R.free r; return (i = n) end /// Implementation of for_all2 using a while loop let forall2_pure_inv (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s0 j) (Seq.index s1 j)) let forall2_pure_inv_b (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) (g:bool) : prop = g == (i `US.lt` n && p (Seq.index s0 (US.v i)) (Seq.index s1 (US.v i))) [@@ __reduce__] let forall2_pred (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (g:bool) : US.t -> vprop = fun i -> A.pts_to a0 p0 s0 `star` A.pts_to a1 p1 s1 `star` R.pts_to r full_perm i `star` pure (forall2_pure_inv n p s0 s1 () i) `star` pure (forall2_pure_inv_b n p s0 s1 () i g) [@@ __reduce__] let forall2_inv (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : bool -> vprop = fun g -> exists_ (forall2_pred n a0 a1 p r p0 p1 s0 s1 () g)
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: FStar.SizeT.t -> a0: Steel.ST.Array.array a -> a1: Steel.ST.Array.array b -> p: (_: a -> _: b -> Prims.bool) -> r: Steel.ST.Reference.ref FStar.SizeT.t -> p0: Steel.FractionalPermission.perm -> p1: Steel.FractionalPermission.perm -> s0: FStar.Ghost.erased (FStar.Seq.Base.seq a) -> s1: FStar.Ghost.erased (FStar.Seq.Base.seq b) -> _: Prims.squash (FStar.Seq.Base.length (FStar.Ghost.reveal s0) == FStar.SizeT.v n /\ FStar.Seq.Base.length (FStar.Ghost.reveal s0) == FStar.Seq.Base.length (FStar.Ghost.reveal s1)) -> _: Prims.unit -> Steel.ST.Effect.STT Prims.bool
Steel.ST.Effect.STT
[]
[]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.bool", "Steel.ST.Reference.ref", "Steel.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.Ghost.reveal", "FStar.SizeT.v", "Prims.unit", "Steel.ST.Util.return", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.ST.Util.exists_", "Steel.Effect.Common.VStar", "Steel.ST.Array.pts_to", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.pure", "Steel.ST.Array.Util.forall2_pure_inv", "Steel.ST.Array.Util.forall2_pure_inv_b", "Steel.Effect.Common.vprop", "Steel.ST.Util.intro_exists", "Steel.ST.Array.Util.forall2_pred", "Steel.ST.Util.intro_pure", "Steel.ST.Array.read", "Prims.op_Equality", "Steel.ST.Reference.read", "Steel.ST.Util.elim_pure", "Steel.ST.Util.elim_exists", "Steel.ST.Array.Util.forall2_inv" ]
[]
false
true
false
false
false
let forall2_cond (#a: Type0) (#b: Type0) (n: US.t) (a0: A.array a) (a1: A.array b) (p: (a -> b -> bool)) (r: R.ref US.t) (p0: perm) (p1: perm) (s0: G.erased (Seq.seq a)) (s1: G.erased (Seq.seq b)) (_: squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ()) =
fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt0 = A.read a0 i in let elt1 = A.read a1 i in return (p elt0 elt1) in intro_pure (forall2_pure_inv n p s0 s1 () i); intro_pure (forall2_pure_inv_b n p s0 s1 () i res); intro_exists i (forall2_pred n a0 a1 p r p0 p1 s0 s1 () res); return res
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.amont_sqr
val amont_sqr:AM.bn_almost_mont_sqr_st t_limbs n_limbs
val amont_sqr:AM.bn_almost_mont_sqr_st t_limbs n_limbs
let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 94, "start_col": 0, "start_line": 93 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.AlmostMontgomery.bn_almost_mont_sqr_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.AlmostMontgomery.bn_almost_mont_sqr", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.bn_inst", "Hacl.Bignum256_32.areduction" ]
[]
false
false
false
true
false
let amont_sqr:AM.bn_almost_mont_sqr_st t_limbs n_limbs =
AM.bn_almost_mont_sqr bn_inst areduction
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.new_bn_from_bytes_be
val new_bn_from_bytes_be: BS.new_bn_from_bytes_be_st t_limbs
val new_bn_from_bytes_be: BS.new_bn_from_bytes_be_st t_limbs
let new_bn_from_bytes_be = BS.new_bn_from_bytes_be
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 163, "start_col": 0, "start_line": 163 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n let mont_ctx_free k = MA.bn_field_free k let mod_precomp k a res = BS.bn_mod_ctx n_limbs bn_slow_precomp k a res let mod_exp_vartime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res let mod_exp_consttime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res let mod_inv_prime_vartime_precomp k a res = BS.mk_bn_mod_inv_prime_ctx n_limbs (BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.new_bn_from_bytes_be_st Hacl.Bignum256_32.t_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.SafeAPI.new_bn_from_bytes_be", "Hacl.Bignum256_32.t_limbs" ]
[]
false
false
false
true
false
let new_bn_from_bytes_be =
BS.new_bn_from_bytes_be
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mod_inv_prime_vartime
val mod_inv_prime_vartime: BS.bn_mod_inv_prime_safe_st t_limbs n_limbs
val mod_inv_prime_vartime: BS.bn_mod_inv_prime_safe_st t_limbs n_limbs
let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 142, "start_col": 0, "start_line": 142 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.bn_mod_inv_prime_safe_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.SafeAPI.mk_bn_mod_inv_prime_safe", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum256_32.exp_vartime" ]
[]
false
false
false
true
false
let mod_inv_prime_vartime =
BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mont_ctx_free
val mont_ctx_free: MA.bn_field_free_st t_limbs
val mont_ctx_free: MA.bn_field_free_st t_limbs
let mont_ctx_free k = MA.bn_field_free k
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 20, "end_line": 148, "start_col": 0, "start_line": 147 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.MontArithmetic.bn_field_free_st Hacl.Bignum256_32.t_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum.MontArithmetic.bn_field_free", "Prims.unit" ]
[]
false
false
false
true
false
let mont_ctx_free k =
MA.bn_field_free k
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.lt_mask
val lt_mask: BN.bn_lt_mask_st t_limbs n_limbs
val lt_mask: BN.bn_lt_mask_st t_limbs n_limbs
let lt_mask = BN.bn_lt_mask n_limbs
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 171, "start_col": 0, "start_line": 171 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n let mont_ctx_free k = MA.bn_field_free k let mod_precomp k a res = BS.bn_mod_ctx n_limbs bn_slow_precomp k a res let mod_exp_vartime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res let mod_exp_consttime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res let mod_inv_prime_vartime_precomp k a res = BS.mk_bn_mod_inv_prime_ctx n_limbs (BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res let new_bn_from_bytes_be = BS.new_bn_from_bytes_be let new_bn_from_bytes_le = BS.new_bn_from_bytes_le let bn_to_bytes_be = Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes let bn_to_bytes_le = Hacl.Bignum.Convert.mk_bn_to_bytes_le true n_bytes
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.bn_lt_mask_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_lt_mask", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs" ]
[]
false
false
false
true
false
let lt_mask =
BN.bn_lt_mask n_limbs
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.new_bn_from_bytes_le
val new_bn_from_bytes_le: BS.new_bn_from_bytes_le_st t_limbs
val new_bn_from_bytes_le: BS.new_bn_from_bytes_le_st t_limbs
let new_bn_from_bytes_le = BS.new_bn_from_bytes_le
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 165, "start_col": 0, "start_line": 165 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n let mont_ctx_free k = MA.bn_field_free k let mod_precomp k a res = BS.bn_mod_ctx n_limbs bn_slow_precomp k a res let mod_exp_vartime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res let mod_exp_consttime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res let mod_inv_prime_vartime_precomp k a res = BS.mk_bn_mod_inv_prime_ctx n_limbs (BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res let new_bn_from_bytes_be = BS.new_bn_from_bytes_be
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.new_bn_from_bytes_le_st Hacl.Bignum256_32.t_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.SafeAPI.new_bn_from_bytes_le", "Hacl.Bignum256_32.t_limbs" ]
[]
false
false
false
true
false
let new_bn_from_bytes_le =
BS.new_bn_from_bytes_le
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mod_inv_prime_vartime_precomp
val mod_inv_prime_vartime_precomp: BS.bn_mod_inv_prime_ctx_st t_limbs n_limbs
val mod_inv_prime_vartime_precomp: BS.bn_mod_inv_prime_ctx_st t_limbs n_limbs
let mod_inv_prime_vartime_precomp k a res = BS.mk_bn_mod_inv_prime_ctx n_limbs (BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 72, "end_line": 161, "start_col": 0, "start_line": 159 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n let mont_ctx_free k = MA.bn_field_free k let mod_precomp k a res = BS.bn_mod_ctx n_limbs bn_slow_precomp k a res let mod_exp_vartime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res let mod_exp_consttime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.bn_mod_inv_prime_ctx_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.SafeAPI.mk_bn_mod_inv_prime_ctx", "FStar.Ghost.hide", "Hacl.Bignum.meta_len", "Hacl.Bignum.ModInv.mk_bn_mod_inv_prime_precomp", "Hacl.Bignum256_32.exp_vartime_precomp", "Prims.unit" ]
[]
false
false
false
true
false
let mod_inv_prime_vartime_precomp k a res =
BS.mk_bn_mod_inv_prime_ctx n_limbs (BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.is_felem_eq_vartime5
val is_felem_eq_vartime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool
let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 && u64_to_UInt64 a2 =. u64_to_UInt64 b2 && u64_to_UInt64 a3 =. u64_to_UInt64 b3 && u64_to_UInt64 a4 =. u64_to_UInt64 b4
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 111, "start_col": 0, "start_line": 105 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL inline_for_extraction noextract let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m inline_for_extraction noextract let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else begin if u64_to_UInt64 f3 >. 0uL then false else begin if u64_to_UInt64 f2 <. 0x1455123uL then true else begin if u64_to_UInt64 f2 >. 0x1455123uL then false else begin if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else begin if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL end end end end end
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.uint64", "Prims.op_AmpAmp", "Lib.IntTypes.op_Equals_Dot", "Lib.IntTypes.U64", "Lib.RawIntTypes.u64_to_UInt64", "Prims.bool" ]
[]
false
false
false
true
false
let is_felem_eq_vartime5 (a0, a1, a2, a3, a4: felem5) (b0, b1, b2, b3, b4: felem5) : bool =
let open Lib.RawIntTypes in u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 && u64_to_UInt64 a2 =. u64_to_UInt64 b2 && u64_to_UInt64 a3 =. u64_to_UInt64 b3 && u64_to_UInt64 a4 =. u64_to_UInt64 b4
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.is_felem_ge_prime_vartime5
val is_felem_ge_prime_vartime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool
let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 68, "start_col": 0, "start_line": 62 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "Prims.op_AmpAmp", "Lib.IntTypes.op_Greater_Equals_Dot", "Lib.IntTypes.U64", "Lib.RawIntTypes.u64_to_UInt64", "FStar.UInt64.__uint_to_t", "Lib.IntTypes.op_Equals_Dot", "Prims.bool" ]
[]
false
false
false
true
false
let is_felem_ge_prime_vartime5 (f0, f1, f2, f3, f4: felem5) : bool =
let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.add5
val add5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 38, "start_col": 0, "start_line": 32 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Dot" ]
[]
false
false
false
true
false
let add5 (a0, a1, a2, a3, a4: felem5) (b0, b1, b2, b3, b4: felem5) : felem5 =
let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0, o1, o2, o3, o4)
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.eq_mask
val eq_mask: BN.bn_eq_mask_st t_limbs n_limbs
val eq_mask: BN.bn_eq_mask_st t_limbs n_limbs
let eq_mask = BN.bn_eq_mask n_limbs
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 173, "start_col": 0, "start_line": 173 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n let mont_ctx_free k = MA.bn_field_free k let mod_precomp k a res = BS.bn_mod_ctx n_limbs bn_slow_precomp k a res let mod_exp_vartime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res let mod_exp_consttime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res let mod_inv_prime_vartime_precomp k a res = BS.mk_bn_mod_inv_prime_ctx n_limbs (BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res let new_bn_from_bytes_be = BS.new_bn_from_bytes_be let new_bn_from_bytes_le = BS.new_bn_from_bytes_le let bn_to_bytes_be = Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes let bn_to_bytes_le = Hacl.Bignum.Convert.mk_bn_to_bytes_le true n_bytes let lt_mask = BN.bn_lt_mask n_limbs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.bn_eq_mask_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_eq_mask", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs" ]
[]
false
false
false
true
false
let eq_mask =
BN.bn_eq_mask n_limbs
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.is_felem_zero_vartime5
val is_felem_zero_vartime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool
let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 58, "start_col": 0, "start_line": 52 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "Prims.op_AmpAmp", "Lib.IntTypes.op_Equals_Dot", "Lib.IntTypes.U64", "Lib.RawIntTypes.u64_to_UInt64", "FStar.UInt64.__uint_to_t", "Prims.bool" ]
[]
false
false
false
true
false
let is_felem_zero_vartime5 (f0, f1, f2, f3, f4: felem5) : bool =
let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.is_felem_lt_prime_minus_order_vartime5
val is_felem_lt_prime_minus_order_vartime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.bool
let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else begin if u64_to_UInt64 f3 >. 0uL then false else begin if u64_to_UInt64 f2 <. 0x1455123uL then true else begin if u64_to_UInt64 f2 >. 0x1455123uL then false else begin if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else begin if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL end end end end end
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 101, "start_col": 0, "start_line": 83 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL inline_for_extraction noextract let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "Lib.IntTypes.op_Greater_Dot", "Lib.IntTypes.U64", "Lib.RawIntTypes.u64_to_UInt64", "FStar.UInt64.__uint_to_t", "Prims.bool", "Lib.IntTypes.op_Less_Dot" ]
[]
false
false
false
true
false
let is_felem_lt_prime_minus_order_vartime5 (f0, f1, f2, f3, f4: felem5) : bool =
let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else if u64_to_UInt64 f3 >. 0uL then false else if u64_to_UInt64 f2 <. 0x1455123uL then true else if u64_to_UInt64 f2 >. 0x1455123uL then false else if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.normalize_weak5
val normalize_weak5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 138, "start_col": 0, "start_line": 136 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL inline_for_extraction noextract let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m inline_for_extraction noextract let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else begin if u64_to_UInt64 f3 >. 0uL then false else begin if u64_to_UInt64 f2 <. 0x1455123uL then true else begin if u64_to_UInt64 f2 >. 0x1455123uL then false else begin if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else begin if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL end end end end end inline_for_extraction noextract let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 && u64_to_UInt64 a2 =. u64_to_UInt64 b2 && u64_to_UInt64 a3 =. u64_to_UInt64 b3 && u64_to_UInt64 a4 =. u64_to_UInt64 b4 inline_for_extraction noextract let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 = let x = t4 >>. 48ul in let t4 = t4 &. mask48 in x, (t0,t1,t2,t3,t4) inline_for_extraction noextract let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in (t0,t1,t2,t3,t4) inline_for_extraction noextract let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 = let t0 = t0 +. x *. u64 0x1000003D1 in carry_round5 (t0,t1,t2,t3,t4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime", "FStar.Pervasives.Native.Mktuple5", "FStar.Pervasives.Native.tuple2", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Spec.K256.Field52.minus_x_mul_pow2_256" ]
[]
false
false
false
true
false
let normalize_weak5 (t0, t1, t2, t3, t4: felem5) : felem5 =
let x, (t0, t1, t2, t3, t4) = minus_x_mul_pow2_256 (t0, t1, t2, t3, t4) in plus_x_mul_pow2_256_minus_prime x (t0, t1, t2, t3, t4)
false
Steel.Primitive.ForkJoin.Unix.fst
Steel.Primitive.ForkJoin.Unix.alloc_pt
val alloc_pt (#a: Type) (x: a) : SteelT (ref a) emp (fun r -> pts_to r full_perm x)
val alloc_pt (#a: Type) (x: a) : SteelT (ref a) emp (fun r -> pts_to r full_perm x)
let alloc_pt (#a:Type) (x:a) : SteelT (ref a) emp (fun r -> pts_to r full_perm x) = alloc_pt x
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 259, "start_col": 0, "start_line": 257 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin.Unix (* This module shows that it's possible to layer continuations on top of SteelT to get a direct style (or Unix style) fork/join. Very much a prototype for now. *) open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.Reference open Steel.Primitive.ForkJoin #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" // (* Some helpers *) let change_slprop_equiv (p q : vprop) (proof : squash (p `equiv` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_equiv p q) let change_slprop_imp (p q : vprop) (proof : squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ()) (* Continuations into unit, but parametrized by the final heap * proposition and with an implicit framing. I think ideally these would * also be parametric in the final type (instead of being hardcoded to * unit) but that means fork needs to be extended to be polymorphic in * at least one of the branches. *) type steelK (t:Type u#aa) (framed:bool) (pre : vprop) (post:t->vprop) = #frame:vprop -> #postf:vprop -> f:(x:t -> SteelT unit (frame `star` post x) (fun _ -> postf)) -> SteelT unit (frame `star` pre) (fun _ -> postf) (* The classic continuation monad *) let return_ a (x:a) (#[@@@ framing_implicit] p: a -> vprop) : steelK a true (return_pre (p x)) p = fun k -> k x private let rearrange3 (p q r:vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) = let open FStar.Tactics in assert (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) by (norm [delta_attr [`%__reduce__]]; canon' false (`true_p) (`true_p)) private let equiv_symmetric (p1 p2:vprop) : Lemma (requires p1 `equiv` p2) (ensures p2 `equiv` p1) = reveal_equiv p1 p2; equiv_symmetric (hp_of p1) (hp_of p2); reveal_equiv p2 p1 private let can_be_split_forall_frame (#a:Type) (p q:post_t a) (frame:vprop) (x:a) : Lemma (requires can_be_split_forall p q) (ensures (frame `star` p x) `can_be_split` (frame `star` q x)) = let frame = hp_of frame in let p = hp_of (p x) in let q = hp_of (q x) in reveal_can_be_split (); assert (slimp p q); slimp_star p q frame frame; Steel.Memory.star_commutative p frame; Steel.Memory.star_commutative q frame let bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:post_t b) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:vprop) (#[@@@ framing_implicit] p:squash (can_be_split_forall (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g))) (#[@@@ framing_implicit] m1 : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] m2:squash (maybe_emp framed_g frame_g)) (f:steelK a framed_f pre_f post_f) (g:(x:a -> steelK b framed_g (pre_g x) post_g)) : steelK b true (pre_f `star` frame_f) (fun y -> post_g y `star` frame_g) = fun #frame (#post:vprop) (k:(y:b -> SteelT unit (frame `star` (post_g y `star` frame_g)) (fun _ -> post))) -> // Need SteelT unit (frame `star` (pre_f `star` frame_f)) (fun _ -> post) change_slprop_equiv (frame `star` (pre_f `star` frame_f)) ((frame `star` frame_f) `star` pre_f) (rearrange3 frame frame_f pre_f; equiv_symmetric ((frame `star` frame_f) `star` pre_f) (frame `star` (pre_f `star` frame_f)) ); f #(frame `star` frame_f) #post ((fun (x:a) -> // Need SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post) change_slprop_imp (frame `star` (post_f x `star` frame_f)) (frame `star` (pre_g x `star` frame_g)) (can_be_split_forall_frame (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g) frame x); g x #(frame `star` frame_g) #post ((fun (y:b) -> k y) <: (y:b -> SteelT unit ((frame `star` frame_g) `star` post_g y) (fun _ -> post))) ) <: (x:a -> SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post))) let subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] p1:squash (can_be_split pre_g pre_f)) (#[@@@ framing_implicit] p2:squash (can_be_split_forall post_f post_g)) (f:steelK a framed_f pre_f post_f) : Tot (steelK a framed_g pre_g post_g) = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post_g x) (fun _ -> postf))) -> change_slprop_imp pre_g pre_f (); f #frame #postf ((fun x -> change_slprop_imp (frame `star` post_f x) (frame `star` post_g x) (can_be_split_forall_frame post_f post_g frame x); k x) <: (x:a -> SteelT unit (frame `star` post_f x) (fun _ -> postf))) // let if_then_else (a:Type u#aa) // (#[@@@ framing_implicit] pre1:pre_t) // (#[@@@ framing_implicit] post1:post_t a) // (f : steelK a pre1 post1) // (g : steelK a pre1 post1) // (p:Type0) : Type = // steelK a pre1 post1 // We did not define a bind between Div and Steel, so we indicate // SteelKF as total to be able to reify and compose it when implementing fork // This module is intended as proof of concept total reifiable reflectable layered_effect { SteelKBase : a:Type -> framed:bool -> pre:vprop -> post:(a->vprop) -> Effect with repr = steelK; return = return_; bind = bind; subcomp = subcomp // if_then_else = if_then_else } effect SteelK (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a false pre post effect SteelKF (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a true pre post // We would need requires/ensures in SteelK to have a binding with Pure. // But for our example, Tot is here sufficient let bind_tot_steelK_ (a:Type) (b:Type) (#framed:eqtype_as_type bool) (#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b) (f:eqtype_as_type unit -> Tot a) (g:(x:a -> steelK b framed pre post)) : steelK b framed pre post = fun #frame #postf (k:(x:b -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> let x = f () in g x #frame #postf k polymonadic_bind (PURE, SteelKBase) |> SteelKBase = bind_tot_steelK_ // (* Sanity check *) let test_lift #p #q (f : unit -> SteelK unit p (fun _ -> q)) : SteelK unit p (fun _ -> q) = (); f (); () (* Identity cont with frame, to eliminate a SteelK *) let idk (#frame:vprop) (#a:Type) (x:a) : SteelT a frame (fun x -> frame) = noop(); return x let kfork (#p:vprop) (#q:vprop) (f : unit -> SteelK unit p (fun _ -> q)) : SteelK (thread q) p (fun _ -> emp) = SteelK?.reflect ( fun (#frame:vprop) (#postf:vprop) (k : (x:(thread q) -> SteelT unit (frame `star` emp) (fun _ -> postf))) -> noop (); let t1 () : SteelT unit (emp `star` p) (fun _ -> q) = let r : steelK unit false p (fun _ -> q) = reify (f ()) in r #emp #q (fun _ -> idk()) in let t2 (t:thread q) () : SteelT unit frame (fun _ -> postf) = k t in let ff () : SteelT unit (p `star` frame) (fun _ -> postf) = fork #p #q #frame #postf t1 t2 in ff()) let kjoin (#p:vprop) (t : thread p) : SteelK unit emp (fun _ -> p) = SteelK?.reflect (fun #f k -> join t; k ()) (* Example *) assume val q : int -> vprop assume val f : unit -> SteelK unit emp (fun _ -> emp) assume val g : i:int -> SteelK unit emp (fun _ -> q i) assume val h : unit -> SteelK unit emp (fun _ -> emp) let example () : SteelK unit emp (fun _ -> q 1 `star` q 2) = let p1:thread (q 1) = kfork (fun () -> g 1) in let p2:thread (q 2) = kfork (fun () -> g 2) in kjoin p1; h(); kjoin p2 let as_steelk_repr' (a:Type) (pre:pre_t) (post:post_t a) (f:unit -> SteelT a pre post) : steelK a false pre post = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> let x = f () in k x let triv_pre (req:vprop) : req_t req = fun _ -> True let triv_post (#a:Type) (req:vprop) (ens:post_t a) : ens_t req a ens = fun _ _ _ -> True let as_steelk_repr (a:Type) (pre:pre_t) (post:post_t a) (f:repr a false pre post (triv_pre pre) (triv_post pre post))// unit -> SteelT a pre post) : steelK a false pre post = as_steelk_repr' a pre post (fun _ -> SteelBase?.reflect f) // let as_steelk_repr' (a:Type) (pre:slprop) (post:post_t a) (f:unit -> SteelT a pre post) // : steelK a pre post // = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> // let x = f () in // k x // let as_steelk (#a:Type) (#pre:slprop) (#post:post_t a) ($f:unit -> SteelT a pre post) // : SteelK a pre post // = SteelK?.reflect (as_steelk_repr a pre post f) open Steel.FractionalPermission sub_effect SteelBase ~> SteelKBase = as_steelk_repr let example2 (r:ref int) : SteelK (thread (pts_to r full_perm 1)) (pts_to r full_perm 0) (fun _ -> emp) = let p1 = kfork (fun _ -> write_pt #_ #0 r 1) in p1
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Primitive.ForkJoin.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Primitive.ForkJoin.Unix.fst" }
[ { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Steel.Effect.SteelT (Steel.Reference.ref a)
Steel.Effect.SteelT
[]
[]
[ "Steel.Reference.alloc_pt", "Steel.Reference.ref", "Steel.Effect.Common.emp", "Steel.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.vprop" ]
[]
false
true
false
false
false
let alloc_pt (#a: Type) (x: a) : SteelT (ref a) emp (fun r -> pts_to r full_perm x) =
alloc_pt x
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.fsub5
val fsub5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> x: Lib.IntTypes.uint64 -> Hacl.Spec.K256.Field52.Definitions.felem5
let fsub5 ((a0,a1,a2,a3,a4):felem5) ((b0,b1,b2,b3,b4):felem5) (x:uint64) : felem5 = let (r0,r1,r2,r3,r4) = fnegate5 (b0,b1,b2,b3,b4) x in add5 (a0,a1,a2,a3,a4) (r0,r1,r2,r3,r4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 266, "start_col": 0, "start_line": 264 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL inline_for_extraction noextract let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m inline_for_extraction noextract let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else begin if u64_to_UInt64 f3 >. 0uL then false else begin if u64_to_UInt64 f2 <. 0x1455123uL then true else begin if u64_to_UInt64 f2 >. 0x1455123uL then false else begin if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else begin if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL end end end end end inline_for_extraction noextract let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 && u64_to_UInt64 a2 =. u64_to_UInt64 b2 && u64_to_UInt64 a3 =. u64_to_UInt64 b3 && u64_to_UInt64 a4 =. u64_to_UInt64 b4 inline_for_extraction noextract let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 = let x = t4 >>. 48ul in let t4 = t4 &. mask48 in x, (t0,t1,t2,t3,t4) inline_for_extraction noextract let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in (t0,t1,t2,t3,t4) inline_for_extraction noextract let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 = let t0 = t0 +. x *. u64 0x1000003D1 in carry_round5 (t0,t1,t2,t3,t4) inline_for_extraction noextract let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4) inline_for_extraction noextract let normalize5 ((f0,f1,f2,f3,f4):felem5) : felem5 = let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime let m_to_one = is_ge_p_m &. u64 1 in let x1 = m_to_one |. x in let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in (k0,k1,k2,k3,k4) inline_for_extraction noextract let fmul5 ((a0,a1,a2,a3,a4):felem5) ((b0,b1,b2,b3,b4):felem5) : felem5 = let r = u64 0x1000003D10 in let d0 = mul64_wide a0 b3 +. mul64_wide a1 b2 +. mul64_wide a2 b1 +. mul64_wide a3 b0 in let c0 = mul64_wide a4 b4 in let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in let d3 = d2 +. mul64_wide a0 b4 +. mul64_wide a1 b3 +. mul64_wide a2 b2 +. mul64_wide a3 b1 +. mul64_wide a4 b0 in let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in let c2 = mul64_wide a0 b0 in let d6 = d5 +. mul64_wide a1 b4 +. mul64_wide a2 b3 +. mul64_wide a3 b2 +. mul64_wide a4 b1 in let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in let u0' = tx |. (u0 <<. 4ul) in let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in let c5 = c4 +. mul64_wide a0 b1 +. mul64_wide a1 b0 in let d8 = d7 +. mul64_wide a2 b4 +. mul64_wide a3 b3 +. mul64_wide a4 b2 in let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in let c8 = c7 +. mul64_wide a0 b2 +. mul64_wide a1 b1 +. mul64_wide a2 b0 in let d10 = d9 +. mul64_wide a3 b4 +. mul64_wide a4 b3 in let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in let r4 = c12 +. t4' in (r0,r1,r2,r3,r4) inline_for_extraction noextract let fsqr5 ((a0,a1,a2,a3,a4):felem5) : felem5 = let r = u64 0x1000003D10 in let d0 = mul64_wide (a0 *. u64 2) a3 +. mul64_wide (a1 *. u64 2) a2 in let c0 = mul64_wide a4 a4 in let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in let a4 = a4 *. u64 2 in let d3 = d2 +. mul64_wide a0 a4 +. mul64_wide (a1 *. u64 2) a3 +. mul64_wide a2 a2 in let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in let c2 = mul64_wide a0 a0 in let d6 = d5 +. mul64_wide a1 a4 +. mul64_wide (a2 *. u64 2) a3 in let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in let u0' = tx |. (u0 <<. 4ul) in let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in let a0 = a0 *. u64 2 in let c5 = c4 +. mul64_wide a0 a1 in let d8 = d7 +. mul64_wide a2 a4 +. mul64_wide a3 a3 in let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in let c8 = c7 +. mul64_wide a0 a2 +. mul64_wide a1 a1 in let d10 = d9 +. mul64_wide a3 a4 in let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in let r4 = c12 +. t4' in (r0,r1,r2,r3,r4) inline_for_extraction noextract let fnegate5 ((a0,a1,a2,a3,a4):felem5) (m:uint64) : felem5 = let r0 = u64 0xffffefffffc2f *. u64 2 *. m -. a0 in let r1 = u64 0xfffffffffffff *. u64 2 *. m -. a1 in let r2 = u64 0xfffffffffffff *. u64 2 *. m -. a2 in let r3 = u64 0xfffffffffffff *. u64 2 *. m -. a3 in let r4 = u64 0xffffffffffff *. u64 2 *. m -. a4 in (r0,r1,r2,r3,r4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> x: Lib.IntTypes.uint64 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple5", "Hacl.Spec.K256.Field52.add5", "FStar.Pervasives.Native.Mktuple5", "Hacl.Spec.K256.Field52.fnegate5" ]
[]
false
false
false
true
false
let fsub5 (a0, a1, a2, a3, a4: felem5) (b0, b1, b2, b3, b4: felem5) (x: uint64) : felem5 =
let r0, r1, r2, r3, r4 = fnegate5 (b0, b1, b2, b3, b4) x in add5 (a0, a1, a2, a3, a4) (r0, r1, r2, r3, r4)
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.sub_mod
val sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs
val sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs
let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 24, "start_col": 0, "start_line": 23 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.bn_sub_mod_n_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_sub_mod_n", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.bn_sub_mod_n_st" ]
[]
false
false
false
true
false
let sub_mod:BN.bn_sub_mod_n_st t_limbs n_limbs =
BN.bn_sub_mod_n n_limbs
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.add_mod
val add_mod: BN.bn_add_mod_n_st t_limbs n_limbs
val add_mod: BN.bn_add_mod_n_st t_limbs n_limbs
let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 21, "start_col": 0, "start_line": 20 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.bn_add_mod_n_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_add_mod_n", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.bn_add_mod_n_st" ]
[]
false
false
false
true
false
let add_mod:BN.bn_add_mod_n_st t_limbs n_limbs =
BN.bn_add_mod_n n_limbs
false
Steel.Primitive.ForkJoin.Unix.fst
Steel.Primitive.ForkJoin.Unix.change_slprop_equiv
val change_slprop_equiv (p q: vprop) (proof: squash (p `equiv` q)) : SteelT unit p (fun _ -> q)
val change_slprop_equiv (p q: vprop) (proof: squash (p `equiv` q)) : SteelT unit p (fun _ -> q)
let change_slprop_equiv (p q : vprop) (proof : squash (p `equiv` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_equiv p q)
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 58, "end_line": 37, "start_col": 0, "start_line": 34 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin.Unix (* This module shows that it's possible to layer continuations on top of SteelT to get a direct style (or Unix style) fork/join. Very much a prototype for now. *) open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.Reference open Steel.Primitive.ForkJoin #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off"
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Primitive.ForkJoin.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Primitive.ForkJoin.Unix.fst" }
[ { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Steel.Effect.Common.vprop -> q: Steel.Effect.Common.vprop -> proof: Prims.squash (Steel.Effect.Common.equiv p q) -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.equiv", "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Memory.mem", "Steel.Effect.Common.reveal_equiv", "Prims.unit" ]
[]
false
true
false
false
false
let change_slprop_equiv (p q: vprop) (proof: squash (p `equiv` q)) : SteelT unit p (fun _ -> q) =
rewrite_slprop p q (fun _ -> proof; reveal_equiv p q)
false
Steel.Primitive.ForkJoin.Unix.fst
Steel.Primitive.ForkJoin.Unix.change_slprop_imp
val change_slprop_imp (p q: vprop) (proof: squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q)
val change_slprop_imp (p q: vprop) (proof: squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q)
let change_slprop_imp (p q : vprop) (proof : squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ())
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 64, "end_line": 42, "start_col": 0, "start_line": 39 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin.Unix (* This module shows that it's possible to layer continuations on top of SteelT to get a direct style (or Unix style) fork/join. Very much a prototype for now. *) open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.Reference open Steel.Primitive.ForkJoin #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" // (* Some helpers *) let change_slprop_equiv (p q : vprop) (proof : squash (p `equiv` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_equiv p q)
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Primitive.ForkJoin.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Primitive.ForkJoin.Unix.fst" }
[ { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Steel.Effect.Common.vprop -> q: Steel.Effect.Common.vprop -> proof: Prims.squash (Steel.Effect.Common.can_be_split p q) -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.can_be_split", "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Memory.mem", "Steel.Effect.Common.reveal_can_be_split", "Prims.unit" ]
[]
false
true
false
false
false
let change_slprop_imp (p q: vprop) (proof: squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q) =
rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ())
false
Steel.Primitive.ForkJoin.Unix.fst
Steel.Primitive.ForkJoin.Unix.bind_tot_steelK_
val bind_tot_steelK_ (a b: Type) (#framed: eqtype_as_type bool) (#[@@@ framing_implicit]pre: pre_t) (#[@@@ framing_implicit]post: post_t b) (f: (eqtype_as_type unit -> Tot a)) (g: (x: a -> steelK b framed pre post)) : steelK b framed pre post
val bind_tot_steelK_ (a b: Type) (#framed: eqtype_as_type bool) (#[@@@ framing_implicit]pre: pre_t) (#[@@@ framing_implicit]post: post_t b) (f: (eqtype_as_type unit -> Tot a)) (g: (x: a -> steelK b framed pre post)) : steelK b framed pre post
let bind_tot_steelK_ (a:Type) (b:Type) (#framed:eqtype_as_type bool) (#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b) (f:eqtype_as_type unit -> Tot a) (g:(x:a -> steelK b framed pre post)) : steelK b framed pre post = fun #frame #postf (k:(x:b -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> let x = f () in g x #frame #postf k
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 25, "end_line": 175, "start_col": 0, "start_line": 165 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin.Unix (* This module shows that it's possible to layer continuations on top of SteelT to get a direct style (or Unix style) fork/join. Very much a prototype for now. *) open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.Reference open Steel.Primitive.ForkJoin #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" // (* Some helpers *) let change_slprop_equiv (p q : vprop) (proof : squash (p `equiv` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_equiv p q) let change_slprop_imp (p q : vprop) (proof : squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ()) (* Continuations into unit, but parametrized by the final heap * proposition and with an implicit framing. I think ideally these would * also be parametric in the final type (instead of being hardcoded to * unit) but that means fork needs to be extended to be polymorphic in * at least one of the branches. *) type steelK (t:Type u#aa) (framed:bool) (pre : vprop) (post:t->vprop) = #frame:vprop -> #postf:vprop -> f:(x:t -> SteelT unit (frame `star` post x) (fun _ -> postf)) -> SteelT unit (frame `star` pre) (fun _ -> postf) (* The classic continuation monad *) let return_ a (x:a) (#[@@@ framing_implicit] p: a -> vprop) : steelK a true (return_pre (p x)) p = fun k -> k x private let rearrange3 (p q r:vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) = let open FStar.Tactics in assert (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) by (norm [delta_attr [`%__reduce__]]; canon' false (`true_p) (`true_p)) private let equiv_symmetric (p1 p2:vprop) : Lemma (requires p1 `equiv` p2) (ensures p2 `equiv` p1) = reveal_equiv p1 p2; equiv_symmetric (hp_of p1) (hp_of p2); reveal_equiv p2 p1 private let can_be_split_forall_frame (#a:Type) (p q:post_t a) (frame:vprop) (x:a) : Lemma (requires can_be_split_forall p q) (ensures (frame `star` p x) `can_be_split` (frame `star` q x)) = let frame = hp_of frame in let p = hp_of (p x) in let q = hp_of (q x) in reveal_can_be_split (); assert (slimp p q); slimp_star p q frame frame; Steel.Memory.star_commutative p frame; Steel.Memory.star_commutative q frame let bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:post_t b) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:vprop) (#[@@@ framing_implicit] p:squash (can_be_split_forall (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g))) (#[@@@ framing_implicit] m1 : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] m2:squash (maybe_emp framed_g frame_g)) (f:steelK a framed_f pre_f post_f) (g:(x:a -> steelK b framed_g (pre_g x) post_g)) : steelK b true (pre_f `star` frame_f) (fun y -> post_g y `star` frame_g) = fun #frame (#post:vprop) (k:(y:b -> SteelT unit (frame `star` (post_g y `star` frame_g)) (fun _ -> post))) -> // Need SteelT unit (frame `star` (pre_f `star` frame_f)) (fun _ -> post) change_slprop_equiv (frame `star` (pre_f `star` frame_f)) ((frame `star` frame_f) `star` pre_f) (rearrange3 frame frame_f pre_f; equiv_symmetric ((frame `star` frame_f) `star` pre_f) (frame `star` (pre_f `star` frame_f)) ); f #(frame `star` frame_f) #post ((fun (x:a) -> // Need SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post) change_slprop_imp (frame `star` (post_f x `star` frame_f)) (frame `star` (pre_g x `star` frame_g)) (can_be_split_forall_frame (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g) frame x); g x #(frame `star` frame_g) #post ((fun (y:b) -> k y) <: (y:b -> SteelT unit ((frame `star` frame_g) `star` post_g y) (fun _ -> post))) ) <: (x:a -> SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post))) let subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] p1:squash (can_be_split pre_g pre_f)) (#[@@@ framing_implicit] p2:squash (can_be_split_forall post_f post_g)) (f:steelK a framed_f pre_f post_f) : Tot (steelK a framed_g pre_g post_g) = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post_g x) (fun _ -> postf))) -> change_slprop_imp pre_g pre_f (); f #frame #postf ((fun x -> change_slprop_imp (frame `star` post_f x) (frame `star` post_g x) (can_be_split_forall_frame post_f post_g frame x); k x) <: (x:a -> SteelT unit (frame `star` post_f x) (fun _ -> postf))) // let if_then_else (a:Type u#aa) // (#[@@@ framing_implicit] pre1:pre_t) // (#[@@@ framing_implicit] post1:post_t a) // (f : steelK a pre1 post1) // (g : steelK a pre1 post1) // (p:Type0) : Type = // steelK a pre1 post1 // We did not define a bind between Div and Steel, so we indicate // SteelKF as total to be able to reify and compose it when implementing fork // This module is intended as proof of concept total reifiable reflectable layered_effect { SteelKBase : a:Type -> framed:bool -> pre:vprop -> post:(a->vprop) -> Effect with repr = steelK; return = return_; bind = bind; subcomp = subcomp // if_then_else = if_then_else } effect SteelK (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a false pre post effect SteelKF (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a true pre post // We would need requires/ensures in SteelK to have a binding with Pure. // But for our example, Tot is here sufficient
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Primitive.ForkJoin.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Primitive.ForkJoin.Unix.fst" }
[ { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
a: Type -> b: Type -> f: (_: FStar.Pervasives.eqtype_as_type Prims.unit -> a) -> g: (x: a -> Steel.Primitive.ForkJoin.Unix.steelK b framed pre post) -> Steel.Primitive.ForkJoin.Unix.steelK b framed pre post
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.eqtype_as_type", "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Prims.unit", "Steel.Primitive.ForkJoin.Unix.steelK", "Steel.Effect.Common.vprop", "Steel.Effect.Common.star" ]
[]
false
false
false
false
false
let bind_tot_steelK_ (a b: Type) (#framed: eqtype_as_type bool) (#[@@@ framing_implicit]pre: pre_t) (#[@@@ framing_implicit]post: post_t b) (f: (eqtype_as_type unit -> Tot a)) (g: (x: a -> steelK b framed pre post)) : steelK b framed pre post =
fun #frame #postf (k: (x: b -> SteelT unit (frame `star` (post x)) (fun _ -> postf))) -> let x = f () in g x #frame #postf k
false
Steel.Primitive.ForkJoin.Unix.fst
Steel.Primitive.ForkJoin.Unix.as_steelk_repr'
val as_steelk_repr' (a: Type) (pre: pre_t) (post: post_t a) (f: (unit -> SteelT a pre post)) : steelK a false pre post
val as_steelk_repr' (a: Type) (pre: pre_t) (post: post_t a) (f: (unit -> SteelT a pre post)) : steelK a false pre post
let as_steelk_repr' (a:Type) (pre:pre_t) (post:post_t a) (f:unit -> SteelT a pre post) : steelK a false pre post = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> let x = f () in k x
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 9, "end_line": 228, "start_col": 0, "start_line": 224 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin.Unix (* This module shows that it's possible to layer continuations on top of SteelT to get a direct style (or Unix style) fork/join. Very much a prototype for now. *) open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.Reference open Steel.Primitive.ForkJoin #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" // (* Some helpers *) let change_slprop_equiv (p q : vprop) (proof : squash (p `equiv` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_equiv p q) let change_slprop_imp (p q : vprop) (proof : squash (p `can_be_split` q)) : SteelT unit p (fun _ -> q) = rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ()) (* Continuations into unit, but parametrized by the final heap * proposition and with an implicit framing. I think ideally these would * also be parametric in the final type (instead of being hardcoded to * unit) but that means fork needs to be extended to be polymorphic in * at least one of the branches. *) type steelK (t:Type u#aa) (framed:bool) (pre : vprop) (post:t->vprop) = #frame:vprop -> #postf:vprop -> f:(x:t -> SteelT unit (frame `star` post x) (fun _ -> postf)) -> SteelT unit (frame `star` pre) (fun _ -> postf) (* The classic continuation monad *) let return_ a (x:a) (#[@@@ framing_implicit] p: a -> vprop) : steelK a true (return_pre (p x)) p = fun k -> k x private let rearrange3 (p q r:vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) = let open FStar.Tactics in assert (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) by (norm [delta_attr [`%__reduce__]]; canon' false (`true_p) (`true_p)) private let equiv_symmetric (p1 p2:vprop) : Lemma (requires p1 `equiv` p2) (ensures p2 `equiv` p1) = reveal_equiv p1 p2; equiv_symmetric (hp_of p1) (hp_of p2); reveal_equiv p2 p1 private let can_be_split_forall_frame (#a:Type) (p q:post_t a) (frame:vprop) (x:a) : Lemma (requires can_be_split_forall p q) (ensures (frame `star` p x) `can_be_split` (frame `star` q x)) = let frame = hp_of frame in let p = hp_of (p x) in let q = hp_of (q x) in reveal_can_be_split (); assert (slimp p q); slimp_star p q frame frame; Steel.Memory.star_commutative p frame; Steel.Memory.star_commutative q frame let bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:post_t b) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:vprop) (#[@@@ framing_implicit] p:squash (can_be_split_forall (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g))) (#[@@@ framing_implicit] m1 : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] m2:squash (maybe_emp framed_g frame_g)) (f:steelK a framed_f pre_f post_f) (g:(x:a -> steelK b framed_g (pre_g x) post_g)) : steelK b true (pre_f `star` frame_f) (fun y -> post_g y `star` frame_g) = fun #frame (#post:vprop) (k:(y:b -> SteelT unit (frame `star` (post_g y `star` frame_g)) (fun _ -> post))) -> // Need SteelT unit (frame `star` (pre_f `star` frame_f)) (fun _ -> post) change_slprop_equiv (frame `star` (pre_f `star` frame_f)) ((frame `star` frame_f) `star` pre_f) (rearrange3 frame frame_f pre_f; equiv_symmetric ((frame `star` frame_f) `star` pre_f) (frame `star` (pre_f `star` frame_f)) ); f #(frame `star` frame_f) #post ((fun (x:a) -> // Need SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post) change_slprop_imp (frame `star` (post_f x `star` frame_f)) (frame `star` (pre_g x `star` frame_g)) (can_be_split_forall_frame (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g) frame x); g x #(frame `star` frame_g) #post ((fun (y:b) -> k y) <: (y:b -> SteelT unit ((frame `star` frame_g) `star` post_g y) (fun _ -> post))) ) <: (x:a -> SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post))) let subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] p1:squash (can_be_split pre_g pre_f)) (#[@@@ framing_implicit] p2:squash (can_be_split_forall post_f post_g)) (f:steelK a framed_f pre_f post_f) : Tot (steelK a framed_g pre_g post_g) = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post_g x) (fun _ -> postf))) -> change_slprop_imp pre_g pre_f (); f #frame #postf ((fun x -> change_slprop_imp (frame `star` post_f x) (frame `star` post_g x) (can_be_split_forall_frame post_f post_g frame x); k x) <: (x:a -> SteelT unit (frame `star` post_f x) (fun _ -> postf))) // let if_then_else (a:Type u#aa) // (#[@@@ framing_implicit] pre1:pre_t) // (#[@@@ framing_implicit] post1:post_t a) // (f : steelK a pre1 post1) // (g : steelK a pre1 post1) // (p:Type0) : Type = // steelK a pre1 post1 // We did not define a bind between Div and Steel, so we indicate // SteelKF as total to be able to reify and compose it when implementing fork // This module is intended as proof of concept total reifiable reflectable layered_effect { SteelKBase : a:Type -> framed:bool -> pre:vprop -> post:(a->vprop) -> Effect with repr = steelK; return = return_; bind = bind; subcomp = subcomp // if_then_else = if_then_else } effect SteelK (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a false pre post effect SteelKF (a:Type) (pre:pre_t) (post:post_t a) = SteelKBase a true pre post // We would need requires/ensures in SteelK to have a binding with Pure. // But for our example, Tot is here sufficient let bind_tot_steelK_ (a:Type) (b:Type) (#framed:eqtype_as_type bool) (#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b) (f:eqtype_as_type unit -> Tot a) (g:(x:a -> steelK b framed pre post)) : steelK b framed pre post = fun #frame #postf (k:(x:b -> SteelT unit (frame `star` post x) (fun _ -> postf))) -> let x = f () in g x #frame #postf k polymonadic_bind (PURE, SteelKBase) |> SteelKBase = bind_tot_steelK_ // (* Sanity check *) let test_lift #p #q (f : unit -> SteelK unit p (fun _ -> q)) : SteelK unit p (fun _ -> q) = (); f (); () (* Identity cont with frame, to eliminate a SteelK *) let idk (#frame:vprop) (#a:Type) (x:a) : SteelT a frame (fun x -> frame) = noop(); return x let kfork (#p:vprop) (#q:vprop) (f : unit -> SteelK unit p (fun _ -> q)) : SteelK (thread q) p (fun _ -> emp) = SteelK?.reflect ( fun (#frame:vprop) (#postf:vprop) (k : (x:(thread q) -> SteelT unit (frame `star` emp) (fun _ -> postf))) -> noop (); let t1 () : SteelT unit (emp `star` p) (fun _ -> q) = let r : steelK unit false p (fun _ -> q) = reify (f ()) in r #emp #q (fun _ -> idk()) in let t2 (t:thread q) () : SteelT unit frame (fun _ -> postf) = k t in let ff () : SteelT unit (p `star` frame) (fun _ -> postf) = fork #p #q #frame #postf t1 t2 in ff()) let kjoin (#p:vprop) (t : thread p) : SteelK unit emp (fun _ -> p) = SteelK?.reflect (fun #f k -> join t; k ()) (* Example *) assume val q : int -> vprop assume val f : unit -> SteelK unit emp (fun _ -> emp) assume val g : i:int -> SteelK unit emp (fun _ -> q i) assume val h : unit -> SteelK unit emp (fun _ -> emp) let example () : SteelK unit emp (fun _ -> q 1 `star` q 2) = let p1:thread (q 1) = kfork (fun () -> g 1) in let p2:thread (q 2) = kfork (fun () -> g 2) in kjoin p1; h(); kjoin p2
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Primitive.ForkJoin.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Primitive.ForkJoin.Unix.fst" }
[ { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive.ForkJoin", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
a: Type -> pre: Steel.Effect.Common.pre_t -> post: Steel.Effect.Common.post_t a -> f: (_: Prims.unit -> Steel.Effect.SteelT a) -> Steel.Primitive.ForkJoin.Unix.steelK a false pre post
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Prims.unit", "Steel.Effect.Common.vprop", "Steel.Effect.Common.star", "Steel.Primitive.ForkJoin.Unix.steelK" ]
[]
false
false
false
false
false
let as_steelk_repr' (a: Type) (pre: pre_t) (post: post_t a) (f: (unit -> SteelT a pre post)) : steelK a false pre post =
fun #frame #postf (k: (x: a -> SteelT unit (frame `star` (post x)) (fun _ -> postf))) -> let x = f () in k x
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.mul15
val mul15 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> c: Lib.IntTypes.uint64 -> Hacl.Spec.K256.Field52.Definitions.felem5
let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 48, "start_col": 0, "start_line": 42 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> c: Lib.IntTypes.uint64 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Star_Dot" ]
[]
false
false
false
true
false
let mul15 (f0, f1, f2, f3, f4: felem5) (c: uint64) : felem5 =
let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0, o1, o2, o3, o4)
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.exp_consttime_precomp
val exp_consttime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs
val exp_consttime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs
let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 128, "start_col": 0, "start_line": 125 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Exponentiation.bn_mod_exp_precomp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Exponentiation.bn_mod_exp_consttime_precomp", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.Exponentiation.bn_mod_exp_amm_bm_consttime_precomp", "Hacl.Bignum256_32.almost_mont_inst", "Hacl.Bignum.Exponentiation.bn_mod_exp_amm_fw_consttime_precomp", "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
true
false
let exp_consttime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul)
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mod_precomp
val mod_precomp: BS.bn_mod_slow_ctx_st t_limbs n_limbs
val mod_precomp: BS.bn_mod_slow_ctx_st t_limbs n_limbs
let mod_precomp k a res = BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 151, "start_col": 0, "start_line": 150 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n let mont_ctx_free k = MA.bn_field_free k
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.bn_mod_slow_ctx_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.SafeAPI.bn_mod_ctx", "FStar.Ghost.hide", "Hacl.Bignum.meta_len", "Hacl.Bignum256_32.bn_slow_precomp", "Prims.unit" ]
[]
false
false
false
true
false
let mod_precomp k a res =
BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.reduction
val reduction:BM.bn_mont_reduction_st t_limbs n_limbs
val reduction:BM.bn_mont_reduction_st t_limbs n_limbs
let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 54, "start_col": 0, "start_line": 53 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Montgomery.bn_mont_reduction_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Montgomery.bn_mont_reduction", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.bn_inst" ]
[]
false
false
false
true
false
let reduction:BM.bn_mont_reduction_st t_limbs n_limbs =
BM.bn_mont_reduction bn_inst
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.areduction
val areduction:AM.bn_almost_mont_reduction_st t_limbs n_limbs
val areduction:AM.bn_almost_mont_reduction_st t_limbs n_limbs
let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 86, "start_col": 0, "start_line": 85 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.AlmostMontgomery.bn_almost_mont_reduction_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.AlmostMontgomery.bn_almost_mont_reduction", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.bn_inst" ]
[]
false
false
false
true
false
let areduction:AM.bn_almost_mont_reduction_st t_limbs n_limbs =
AM.bn_almost_mont_reduction bn_inst
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.carry_round5
val carry_round5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in (t0,t1,t2,t3,t4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 126, "start_col": 0, "start_line": 121 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL inline_for_extraction noextract let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m inline_for_extraction noextract let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else begin if u64_to_UInt64 f3 >. 0uL then false else begin if u64_to_UInt64 f2 <. 0x1455123uL then true else begin if u64_to_UInt64 f2 >. 0x1455123uL then false else begin if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else begin if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL end end end end end inline_for_extraction noextract let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 && u64_to_UInt64 a2 =. u64_to_UInt64 b2 && u64_to_UInt64 a3 =. u64_to_UInt64 b3 && u64_to_UInt64 a4 =. u64_to_UInt64 b4 inline_for_extraction noextract let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 = let x = t4 >>. 48ul in let t4 = t4 &. mask48 in x, (t0,t1,t2,t3,t4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Amp_Dot", "Hacl.Spec.K256.Field52.Definitions.mask52", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
true
false
let carry_round5 (t0, t1, t2, t3, t4: felem5) : felem5 =
let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in (t0, t1, t2, t3, t4)
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.exp_vartime_precomp
val exp_vartime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs
val exp_vartime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs
let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 63, "end_line": 122, "start_col": 0, "start_line": 119 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Exponentiation.bn_mod_exp_precomp_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Exponentiation.bn_mod_exp_vartime_precomp", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.Exponentiation.bn_mod_exp_amm_bm_vartime_precomp", "Hacl.Bignum256_32.almost_mont_inst", "Hacl.Bignum.Exponentiation.bn_mod_exp_amm_fw_vartime_precomp", "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
true
false
let exp_vartime_precomp:BE.bn_mod_exp_precomp_st t_limbs n_limbs =
BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul)
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mod_exp_vartime_precomp
val mod_exp_vartime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs
val mod_exp_vartime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs
let mod_exp_vartime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 66, "end_line": 154, "start_col": 0, "start_line": 153 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n let mont_ctx_free k = MA.bn_field_free k let mod_precomp k a res = BS.bn_mod_ctx n_limbs bn_slow_precomp k a res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.bn_mod_exp_ctx_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum256_32.n_limbs", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Bignum.SafeAPI.mk_bn_mod_exp_ctx", "FStar.Ghost.hide", "Hacl.Bignum.meta_len", "Hacl.Bignum256_32.exp_vartime_precomp", "Prims.unit" ]
[]
false
false
false
true
false
let mod_exp_vartime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
false
SfLists.fst
SfLists.app
val app : ilist -> ilist -> Tot ilist
val app : ilist -> ilist -> Tot ilist
let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2)
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 45, "start_col": 0, "start_line": 42 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
l1: SfLists.ilist -> l2: SfLists.ilist -> SfLists.ilist
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "Prims.int", "SfLists.Cons", "SfLists.app" ]
[ "recursion" ]
false
false
false
true
false
let rec app l1 l2 =
match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2)
false
SfLists.fst
SfLists.length
val length : ilist -> Tot nat
val length : ilist -> Tot nat
let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 33, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.op_Addition", "SfLists.length", "Prims.nat" ]
[ "recursion" ]
false
false
false
true
false
let rec length l =
match l with | Nil -> 0 | Cons h t -> length t + 1
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mul
val mul: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_mul_st t_limbs n_limbs a
val mul: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_mul_st t_limbs n_limbs a
let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 27, "start_col": 0, "start_line": 26 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Bignum256_32.lbignum Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs -> Hacl.Bignum.bn_karatsuba_mul_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs a
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum256_32.lbignum", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.bn_mul", "Hacl.Bignum.bn_karatsuba_mul_st" ]
[]
false
false
false
false
false
let mul (a: lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a =
BN.bn_mul n_limbs n_limbs a
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.is_felem_ge_prime5
val is_felem_ge_prime5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Lib.IntTypes.uint64
let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 79, "start_col": 0, "start_line": 72 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> Lib.IntTypes.uint64
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.gte_mask", "Lib.IntTypes.u64", "Lib.IntTypes.eq_mask", "Hacl.Spec.K256.Field52.Definitions.mask52", "Hacl.Spec.K256.Field52.Definitions.mask48" ]
[]
false
false
false
true
false
let is_felem_ge_prime5 (t0, t1, t2, t3, t4: felem5) : uint64 =
let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.sqr
val sqr: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_sqr_st t_limbs n_limbs a
val sqr: a:lbignum t_limbs n_limbs -> BN.bn_karatsuba_sqr_st t_limbs n_limbs a
let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 30, "start_col": 0, "start_line": 29 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Bignum256_32.lbignum Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs -> Hacl.Bignum.bn_karatsuba_sqr_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs a
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum256_32.lbignum", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Hacl.Bignum.bn_sqr", "Hacl.Bignum.bn_karatsuba_sqr_st" ]
[]
false
false
false
false
false
let sqr (a: lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a =
BN.bn_sqr n_limbs a
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.load_felem5
val load_felem5 : _: Hacl.Spec.K256.Field52.Definitions.felem4 -> Hacl.Spec.K256.Field52.Definitions.felem5
let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 19, "start_col": 0, "start_line": 13 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem4 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem4", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Bar_Dot", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.u64", "Hacl.Spec.K256.Field52.Definitions.mask52", "Hacl.Spec.K256.Field52.Definitions.felem5" ]
[]
false
false
false
true
false
let load_felem5 (s0, s1, s2, s3: felem4) : felem5 =
let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0, f1, f2, f3, f4)
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.store_felem5
val store_felem5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem4
let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 28, "start_col": 0, "start_line": 23 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem4
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple4", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Bar_Dot", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Less_Less_Dot", "Hacl.Spec.K256.Field52.Definitions.felem4" ]
[]
false
false
false
true
false
let store_felem5 (f0, f1, f2, f3, f4: felem5) : felem4 =
let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0, o1, o2, o3)
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mod
val mod: BS.bn_mod_slow_safe_st t_limbs n_limbs
val mod: BS.bn_mod_slow_safe_st t_limbs n_limbs
let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 94, "end_line": 113, "start_col": 0, "start_line": 112 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.bn_mod_slow_safe_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_limbs", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.SafeAPI.mk_bn_mod_slow_safe", "Hacl.Bignum.ModReduction.mk_bn_mod_slow", "Hacl.Bignum256_32.precompr2", "Hacl.Bignum256_32.bn_slow_precomp", "Prims.bool" ]
[]
false
false
false
true
false
let mod n a res =
BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res
false
SfLists.fst
SfLists.repeat
val repeat : int -> count:nat -> Tot ilist
val repeat : int -> count:nat -> Tot ilist
let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1))
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 39, "start_col": 0, "start_line": 36 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.int -> count: Prims.nat -> SfLists.ilist
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.nat", "SfLists.Nil", "SfLists.Cons", "SfLists.repeat", "Prims.op_Subtraction", "SfLists.ilist" ]
[ "recursion" ]
false
false
false
true
false
let rec repeat n count =
match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1))
false
SfLists.fst
SfLists.hd
val hd : l:ilist{l =!= Nil} -> Tot int
val hd : l:ilist{l =!= Nil} -> Tot int
let hd l = match l with | Cons h t -> h
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 76, "start_col": 0, "start_line": 74 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist{~(l == SfLists.Nil)} -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "Prims.l_not", "Prims.eq2", "SfLists.Nil", "Prims.int" ]
[]
false
false
false
false
false
let hd l =
match l with | Cons h t -> h
false
SfLists.fst
SfLists.snoc
val snoc : ilist -> int -> Tot ilist
val snoc : ilist -> int -> Tot ilist
let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v)
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 121, "start_col": 0, "start_line": 118 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> v: Prims.int -> SfLists.ilist
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "Prims.int", "SfLists.Cons", "SfLists.Nil", "SfLists.snoc" ]
[ "recursion" ]
false
false
false
true
false
let rec snoc l v =
match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v)
false
SfLists.fst
SfLists.app_length
val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2)))
val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2)))
let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 115, "start_col": 0, "start_line": 112 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
l1: SfLists.ilist -> l2: SfLists.ilist -> FStar.Pervasives.Lemma (ensures SfLists.length (SfLists.app l1 l2) = SfLists.length l1 + SfLists.length l2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "SfLists.app_length", "Prims.unit" ]
[ "recursion" ]
false
false
true
false
false
let rec app_length l1 l2 =
match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2
false
SfLists.fst
SfLists.existsb'
val existsb': l:ilist -> f:(int -> Tot bool) -> Tot bool
val existsb': l:ilist -> f:(int -> Tot bool) -> Tot bool
let existsb' l f = let g x = not (f x) in let b = forallb l g in not b
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 259, "start_col": 0, "start_line": 256 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> () val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2) let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> () val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a let rec fold_left f l a = match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a) val app_cons: l:ilist -> hd:int -> tl:ilist -> Lemma (app l (Cons hd tl) = app (app l (Cons hd Nil)) (tl)) let rec app_cons l hd tl = match l with | Nil -> () | Cons hd' tl' -> let ih = app_cons tl' hd tl in () val snoc_app: l:ilist -> h:int -> Lemma (snoc l h = app l (Cons h Nil)) let rec snoc_app l h = match l with | Nil -> () | Cons hd tl -> let _ = snoc_app tl h in () val rev_app: tl:ilist -> hd:int -> Lemma (rev (Cons hd tl) = app (rev tl) (Cons hd Nil)) let rev_app tl hd = snoc_app (rev tl) hd val fold_left_cons_is_rev: l:ilist -> l':ilist -> Lemma (fold_left Cons l l' = app (rev l) l') let rec fold_left_cons_is_rev l l' = match l with | Nil -> () | Cons hd tl -> let _ = fold_left_cons_is_rev tl (Cons hd l') in let _ = app_cons (rev tl) hd l' in let _ = rev_app tl hd in () (*****) val forallb: l:ilist -> f:(int -> Tot bool) -> Tot bool let rec forallb l f = match l with | Nil -> true | Cons x l' -> let b1 = f x in let b2 = forallb l' f in b1 && b2 val existsb: l:ilist -> f:(int -> Tot bool) -> Tot bool let rec existsb l f = match l with | Nil -> false | Cons x l' -> let b1 = f x in let b2 = existsb l' f in b1 || b2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> f: (_: Prims.int -> Prims.bool) -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.bool", "Prims.op_Negation", "SfLists.forallb" ]
[]
false
false
false
true
false
let existsb' l f =
let g x = not (f x) in let b = forallb l g in not b
false
SfLists.fst
SfLists.tl
val tl : l:ilist{l =!= Nil} -> Tot ilist
val tl : l:ilist{l =!= Nil} -> Tot ilist
let tl l = match l with | Cons h t -> t
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 97, "start_col": 0, "start_line": 95 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist{~(l == SfLists.Nil)} -> SfLists.ilist
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "Prims.l_not", "Prims.eq2", "SfLists.Nil", "Prims.int" ]
[]
false
false
false
false
false
let tl l =
match l with | Cons h t -> t
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.mod_exp_consttime_precomp
val mod_exp_consttime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs
val mod_exp_consttime_precomp: BS.bn_mod_exp_ctx_st t_limbs n_limbs
let mod_exp_consttime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 157, "start_col": 0, "start_line": 156 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n let mont_ctx_free k = MA.bn_field_free k let mod_precomp k a res = BS.bn_mod_ctx n_limbs bn_slow_precomp k a res let mod_exp_vartime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.SafeAPI.bn_mod_exp_ctx_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum256_32.n_limbs", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Bignum.SafeAPI.mk_bn_mod_exp_ctx", "FStar.Ghost.hide", "Hacl.Bignum.meta_len", "Hacl.Bignum256_32.exp_consttime_precomp", "Prims.unit" ]
[]
false
false
false
true
false
let mod_exp_consttime_precomp k a bBits b res =
BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.minus_x_mul_pow2_256
val minus_x_mul_pow2_256 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Lib.IntTypes.uint64 * Hacl.Spec.K256.Field52.Definitions.felem5
let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 = let x = t4 >>. 48ul in let t4 = t4 &. mask48 in x, (t0,t1,t2,t3,t4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 117, "start_col": 0, "start_line": 115 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL inline_for_extraction noextract let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m inline_for_extraction noextract let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else begin if u64_to_UInt64 f3 >. 0uL then false else begin if u64_to_UInt64 f2 <. 0x1455123uL then true else begin if u64_to_UInt64 f2 >. 0x1455123uL then false else begin if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else begin if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL end end end end end inline_for_extraction noextract let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 && u64_to_UInt64 a2 =. u64_to_UInt64 b2 && u64_to_UInt64 a3 =. u64_to_UInt64 b3 && u64_to_UInt64 a4 =. u64_to_UInt64 b4
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> Lib.IntTypes.uint64 * Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Amp_Dot", "Hacl.Spec.K256.Field52.Definitions.mask48", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.UInt32.__uint_to_t", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
true
false
let minus_x_mul_pow2_256 (t0, t1, t2, t3, t4: felem5) : uint64 & felem5 =
let x = t4 >>. 48ul in let t4 = t4 &. mask48 in x, (t0, t1, t2, t3, t4)
false
SfLists.fst
SfLists.length_snoc
val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1))
val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1))
let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 134, "start_col": 0, "start_line": 131 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.int -> l: SfLists.ilist -> FStar.Pervasives.Lemma (ensures SfLists.length (SfLists.snoc l n) = SfLists.length l + 1)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "SfLists.ilist", "SfLists.length_snoc", "Prims.unit" ]
[ "recursion" ]
false
false
true
false
false
let rec length_snoc n l =
match l with | Nil -> () | Cons h t -> length_snoc n t
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime
val plus_x_mul_pow2_256_minus_prime : x: Lib.IntTypes.uint64 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 = let t0 = t0 +. x *. u64 0x1000003D1 in carry_round5 (t0,t1,t2,t3,t4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 132, "start_col": 0, "start_line": 130 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL inline_for_extraction noextract let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m inline_for_extraction noextract let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else begin if u64_to_UInt64 f3 >. 0uL then false else begin if u64_to_UInt64 f2 <. 0x1455123uL then true else begin if u64_to_UInt64 f2 >. 0x1455123uL then false else begin if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else begin if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL end end end end end inline_for_extraction noextract let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 && u64_to_UInt64 a2 =. u64_to_UInt64 b2 && u64_to_UInt64 a3 =. u64_to_UInt64 b3 && u64_to_UInt64 a4 =. u64_to_UInt64 b4 inline_for_extraction noextract let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 = let x = t4 >>. 48ul in let t4 = t4 &. mask48 in x, (t0,t1,t2,t3,t4) inline_for_extraction noextract let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in (t0,t1,t2,t3,t4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Lib.IntTypes.uint64 -> _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint64", "Hacl.Spec.K256.Field52.Definitions.felem5", "Hacl.Spec.K256.Field52.carry_round5", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.op_Star_Dot", "Lib.IntTypes.u64" ]
[]
false
false
false
true
false
let plus_x_mul_pow2_256_minus_prime (x: uint64) (t0, t1, t2, t3, t4: felem5) : felem5 =
let t0 = t0 +. x *. u64 0x1000003D1 in carry_round5 (t0, t1, t2, t3, t4)
false
SfLists.fst
SfLists.rev_length
val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l))
val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l))
let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 141, "start_col": 0, "start_line": 138 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> FStar.Pervasives.Lemma (ensures SfLists.length (SfLists.rev l) = SfLists.length l)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "SfLists.rev_length", "Prims.unit", "SfLists.length_snoc", "SfLists.rev" ]
[ "recursion" ]
false
false
true
false
false
let rec rev_length l =
match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t
false
SfLists.fst
SfLists.app_nil
val app_nil : l:ilist -> Lemma (ensures (app l Nil = l))
val app_nil : l:ilist -> Lemma (ensures (app l Nil = l))
let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 71, "start_col": 0, "start_line": 68 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> FStar.Pervasives.Lemma (ensures SfLists.app l SfLists.Nil = l)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "SfLists.app_nil", "Prims.unit" ]
[ "recursion" ]
false
false
true
false
false
let rec app_nil l =
match l with | Nil -> () | Cons h t -> app_nil t
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.normalize5
val normalize5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
let normalize5 ((f0,f1,f2,f3,f4):felem5) : felem5 = let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime let m_to_one = is_ge_p_m &. u64 1 in let x1 = m_to_one |. x in let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in (k0,k1,k2,k3,k4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 150, "start_col": 0, "start_line": 142 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL inline_for_extraction noextract let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m inline_for_extraction noextract let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else begin if u64_to_UInt64 f3 >. 0uL then false else begin if u64_to_UInt64 f2 <. 0x1455123uL then true else begin if u64_to_UInt64 f2 >. 0x1455123uL then false else begin if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else begin if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL end end end end end inline_for_extraction noextract let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 && u64_to_UInt64 a2 =. u64_to_UInt64 b2 && u64_to_UInt64 a3 =. u64_to_UInt64 b3 && u64_to_UInt64 a4 =. u64_to_UInt64 b4 inline_for_extraction noextract let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 = let x = t4 >>. 48ul in let t4 = t4 &. mask48 in x, (t0,t1,t2,t3,t4) inline_for_extraction noextract let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in (t0,t1,t2,t3,t4) inline_for_extraction noextract let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 = let t0 = t0 +. x *. u64 0x1000003D1 in carry_round5 (t0,t1,t2,t3,t4) inline_for_extraction noextract let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "FStar.Pervasives.Native.tuple2", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Spec.K256.Field52.minus_x_mul_pow2_256", "Hacl.Spec.K256.Field52.plus_x_mul_pow2_256_minus_prime", "Lib.IntTypes.op_Bar_Dot", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.u64", "Hacl.Spec.K256.Field52.is_felem_ge_prime5", "Hacl.Spec.K256.Field52.normalize_weak5" ]
[]
false
false
false
true
false
let normalize5 (f0, f1, f2, f3, f4: felem5) : felem5 =
let t0, t1, t2, t3, t4 = normalize_weak5 (f0, f1, f2, f3, f4) in let x, (r0, r1, r2, r3, r4) = minus_x_mul_pow2_256 (t0, t1, t2, t3, t4) in let is_ge_p_m = is_felem_ge_prime5 (r0, r1, r2, r3, r4) in let m_to_one = is_ge_p_m &. u64 1 in let x1 = m_to_one |. x in let s0, s1, s2, s3, s4 = plus_x_mul_pow2_256_minus_prime x1 (r0, r1, r2, r3, r4) in let x2, (k0, k1, k2, k3, k4) = minus_x_mul_pow2_256 (s0, s1, s2, s3, s4) in (k0, k1, k2, k3, k4)
false
SfLists.fst
SfLists.snoc_cons
val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l))
val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l))
let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in ()
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 177, "start_col": 0, "start_line": 173 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> h: Prims.int -> FStar.Pervasives.Lemma (ensures SfLists.rev (SfLists.snoc l h) = SfLists.Cons h (SfLists.rev l))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.unit", "SfLists.snoc_cons" ]
[ "recursion" ]
false
false
true
false
false
let rec snoc_cons l h =
match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in ()
false
SfLists.fst
SfLists.foo3
val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1)))
val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1)))
let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t)
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 162, "start_col": 0, "start_line": 159 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> n: Prims.int -> m: Prims.nat -> Prims.Pure Prims.unit
Prims.Pure
[]
[]
[ "SfLists.ilist", "Prims.int", "Prims.nat", "SfLists.foo3", "SfLists.length", "Prims.unit" ]
[ "recursion" ]
false
false
false
false
false
let rec foo3 l n m =
match l with | Nil -> () | Cons h t -> foo3 t n (length t)
false
SfLists.fst
SfLists.app_cons
val app_cons: l:ilist -> hd:int -> tl:ilist -> Lemma (app l (Cons hd tl) = app (app l (Cons hd Nil)) (tl))
val app_cons: l:ilist -> hd:int -> tl:ilist -> Lemma (app l (Cons hd tl) = app (app l (Cons hd Nil)) (tl))
let rec app_cons l hd tl = match l with | Nil -> () | Cons hd' tl' -> let ih = app_cons tl' hd tl in ()
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 214, "start_col": 0, "start_line": 210 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> () val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2) let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> () val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a let rec fold_left f l a = match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> hd: Prims.int -> tl: SfLists.ilist -> FStar.Pervasives.Lemma (ensures SfLists.app l (SfLists.Cons hd tl) = SfLists.app (SfLists.app l (SfLists.Cons hd SfLists.Nil)) tl)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.unit", "SfLists.app_cons" ]
[ "recursion" ]
false
false
true
false
false
let rec app_cons l hd tl =
match l with | Nil -> () | Cons hd' tl' -> let ih = app_cons tl' hd tl in ()
false
SfLists.fst
SfLists.foo2
val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m))
val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m))
let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1))
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 154, "start_col": 0, "start_line": 151 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> m: Prims.nat -> l: SfLists.ilist -> Prims.Pure Prims.unit
Prims.Pure
[]
[]
[ "Prims.nat", "SfLists.ilist", "Prims.int", "SfLists.foo2", "Prims.op_Subtraction", "SfLists.repeat", "Prims.unit" ]
[ "recursion" ]
false
false
false
false
false
let rec foo2 n m l =
match m with | 0 -> () | _ -> foo2 n (m - 1) (repeat n (m - 1))
false
SfLists.fst
SfLists.tl_strange
val tl_strange : l:ilist -> Tot ilist
val tl_strange : l:ilist -> Tot ilist
let tl_strange l = match l with | Nil -> Nil | Cons h t -> t
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 84, "start_col": 0, "start_line": 81 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> SfLists.ilist
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "SfLists.Nil", "Prims.int" ]
[]
false
false
false
true
false
let tl_strange l =
match l with | Nil -> Nil | Cons h t -> t
false
SfLists.fst
SfLists.app_assoc
val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3))
val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3))
let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 108, "start_col": 0, "start_line": 105 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
l1: SfLists.ilist -> l2: SfLists.ilist -> l3: SfLists.ilist -> FStar.Pervasives.Lemma (ensures SfLists.app (SfLists.app l1 l2) l3 = SfLists.app l1 (SfLists.app l2 l3))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "SfLists.app_assoc", "Prims.unit" ]
[ "recursion" ]
false
false
true
false
false
let rec app_assoc l1 l2 l3 =
match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3
false
SfLists.fst
SfLists.rev
val rev : ilist -> Tot ilist
val rev : ilist -> Tot ilist
let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 127, "start_col": 0, "start_line": 124 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> SfLists.ilist
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "SfLists.Nil", "Prims.int", "SfLists.snoc", "SfLists.rev" ]
[ "recursion" ]
false
false
false
true
false
let rec rev l =
match l with | Nil -> Nil | Cons h t -> snoc (rev t) h
false
SfLists.fst
SfLists.snoc_app
val snoc_app: l:ilist -> h:int -> Lemma (snoc l h = app l (Cons h Nil))
val snoc_app: l:ilist -> h:int -> Lemma (snoc l h = app l (Cons h Nil))
let rec snoc_app l h = match l with | Nil -> () | Cons hd tl -> let _ = snoc_app tl h in ()
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 221, "start_col": 0, "start_line": 217 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> () val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2) let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> () val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a let rec fold_left f l a = match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a) val app_cons: l:ilist -> hd:int -> tl:ilist -> Lemma (app l (Cons hd tl) = app (app l (Cons hd Nil)) (tl)) let rec app_cons l hd tl = match l with | Nil -> () | Cons hd' tl' -> let ih = app_cons tl' hd tl in ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> h: Prims.int -> FStar.Pervasives.Lemma (ensures SfLists.snoc l h = SfLists.app l (SfLists.Cons h SfLists.Nil))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.unit", "SfLists.snoc_app" ]
[ "recursion" ]
false
false
true
false
false
let rec snoc_app l h =
match l with | Nil -> () | Cons hd tl -> let _ = snoc_app tl h in ()
false
SfLists.fst
SfLists.rev_injective
val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2)
val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2)
let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> ()
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 202, "start_col": 0, "start_line": 196 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
l1: SfLists.ilist -> l2: SfLists.ilist -> FStar.Pervasives.Lemma (ensures SfLists.rev l1 = SfLists.rev l2 ==> l1 = l2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "FStar.Pervasives.Native.Mktuple2", "Prims.int", "Prims.unit", "SfLists.snoc_injective", "SfLists.rev", "SfLists.rev_injective" ]
[ "recursion" ]
false
false
true
false
false
let rec rev_injective l1 l2 =
match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> ()
false
SfLists.fst
SfLists.rev_app
val rev_app: tl:ilist -> hd:int -> Lemma (rev (Cons hd tl) = app (rev tl) (Cons hd Nil))
val rev_app: tl:ilist -> hd:int -> Lemma (rev (Cons hd tl) = app (rev tl) (Cons hd Nil))
let rev_app tl hd = snoc_app (rev tl) hd
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 224, "start_col": 0, "start_line": 224 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> () val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2) let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> () val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a let rec fold_left f l a = match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a) val app_cons: l:ilist -> hd:int -> tl:ilist -> Lemma (app l (Cons hd tl) = app (app l (Cons hd Nil)) (tl)) let rec app_cons l hd tl = match l with | Nil -> () | Cons hd' tl' -> let ih = app_cons tl' hd tl in () val snoc_app: l:ilist -> h:int -> Lemma (snoc l h = app l (Cons h Nil)) let rec snoc_app l h = match l with | Nil -> () | Cons hd tl -> let _ = snoc_app tl h in ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
tl: SfLists.ilist -> hd: Prims.int -> FStar.Pervasives.Lemma (ensures SfLists.rev (SfLists.Cons hd tl) = SfLists.app (SfLists.rev tl) (SfLists.Cons hd SfLists.Nil))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "SfLists.snoc_app", "SfLists.rev", "Prims.unit" ]
[]
true
false
true
false
false
let rev_app tl hd =
snoc_app (rev tl) hd
false
SfLists.fst
SfLists.fold_left_cons_is_rev
val fold_left_cons_is_rev: l:ilist -> l':ilist -> Lemma (fold_left Cons l l' = app (rev l) l')
val fold_left_cons_is_rev: l:ilist -> l':ilist -> Lemma (fold_left Cons l l' = app (rev l) l')
let rec fold_left_cons_is_rev l l' = match l with | Nil -> () | Cons hd tl -> let _ = fold_left_cons_is_rev tl (Cons hd l') in let _ = app_cons (rev tl) hd l' in let _ = rev_app tl hd in ()
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 233, "start_col": 0, "start_line": 227 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> () val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2) let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> () val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a let rec fold_left f l a = match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a) val app_cons: l:ilist -> hd:int -> tl:ilist -> Lemma (app l (Cons hd tl) = app (app l (Cons hd Nil)) (tl)) let rec app_cons l hd tl = match l with | Nil -> () | Cons hd' tl' -> let ih = app_cons tl' hd tl in () val snoc_app: l:ilist -> h:int -> Lemma (snoc l h = app l (Cons h Nil)) let rec snoc_app l h = match l with | Nil -> () | Cons hd tl -> let _ = snoc_app tl h in () val rev_app: tl:ilist -> hd:int -> Lemma (rev (Cons hd tl) = app (rev tl) (Cons hd Nil)) let rev_app tl hd = snoc_app (rev tl) hd
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> l': SfLists.ilist -> FStar.Pervasives.Lemma (ensures SfLists.fold_left SfLists.Cons l l' = SfLists.app (SfLists.rev l) l')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.unit", "SfLists.rev_app", "SfLists.app_cons", "SfLists.rev", "SfLists.fold_left_cons_is_rev", "SfLists.Cons" ]
[ "recursion" ]
false
false
true
false
false
let rec fold_left_cons_is_rev l l' =
match l with | Nil -> () | Cons hd tl -> let _ = fold_left_cons_is_rev tl (Cons hd l') in let _ = app_cons (rev tl) hd l' in let _ = rev_app tl hd in ()
false
SfLists.fst
SfLists.rev_involutive
val rev_involutive: l:ilist -> Lemma (rev (rev l) = l)
val rev_involutive: l:ilist -> Lemma (rev (rev l) = l)
let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in ()
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 185, "start_col": 0, "start_line": 180 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> FStar.Pervasives.Lemma (ensures SfLists.rev (SfLists.rev l) = l)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.unit", "SfLists.snoc_cons", "SfLists.rev", "SfLists.rev_involutive" ]
[ "recursion" ]
false
false
true
false
false
let rec rev_involutive l =
match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in ()
false
SfLists.fst
SfLists.snoc_injective
val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2)
val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2)
let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> ()
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 193, "start_col": 0, "start_line": 188 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
l1: SfLists.ilist -> h1: Prims.int -> l2: SfLists.ilist -> h2: Prims.int -> FStar.Pervasives.Lemma (ensures SfLists.snoc l1 h1 = SfLists.snoc l2 h2 ==> l1 = l2 /\ h1 = h2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "SfLists.snoc_injective" ]
[ "recursion" ]
false
false
true
false
false
let rec snoc_injective l1 h1 l2 h2 =
match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> ()
false
Hacl.Bignum256_32.fst
Hacl.Bignum256_32.bn_to_bytes_le
val bn_to_bytes_le: Hacl.Bignum.Convert.bn_to_bytes_le_st t_limbs n_bytes
val bn_to_bytes_le: Hacl.Bignum.Convert.bn_to_bytes_le_st t_limbs n_bytes
let bn_to_bytes_le = Hacl.Bignum.Convert.mk_bn_to_bytes_le true n_bytes
{ "file_name": "code/bignum/Hacl.Bignum256_32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 169, "start_col": 0, "start_line": 169 }
module Hacl.Bignum256_32 open FStar.Mul module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module AM = Hacl.Bignum.AlmostMontgomery module BE = Hacl.Bignum.Exponentiation module BR = Hacl.Bignum.ModReduction module BI = Hacl.Bignum.ModInv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let add: BN.bn_add_eq_len_st t_limbs n_limbs = BN.bn_add_eq_len n_limbs let sub: BN.bn_sub_eq_len_st t_limbs n_limbs = BN.bn_sub_eq_len n_limbs let add_mod: BN.bn_add_mod_n_st t_limbs n_limbs = BN.bn_add_mod_n n_limbs let sub_mod: BN.bn_sub_mod_n_st t_limbs n_limbs = BN.bn_sub_mod_n n_limbs let mul (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_mul_st t_limbs n_limbs a = BN.bn_mul n_limbs n_limbs a let sqr (a:lbignum t_limbs n_limbs) : BN.bn_karatsuba_sqr_st t_limbs n_limbs a = BN.bn_sqr n_limbs a //BN.bn_mul n_limbs n_limbs a a inline_for_extraction noextract instance bn_inst: BN.bn t_limbs = { BN.len = n_limbs; BN.add; BN.sub; BN.add_mod_n = add_mod; BN.sub_mod_n = sub_mod; BN.mul; BN.sqr } [@CInline] let mont_check: BM.bn_check_modulus_st t_limbs n_limbs = BM.bn_check_modulus [@CInline] let precompr2: BM.bn_precomp_r2_mod_n_st t_limbs n_limbs = BM.bn_precomp_r2_mod_n bn_inst [@CInline] let reduction: BM.bn_mont_reduction_st t_limbs n_limbs = BM.bn_mont_reduction bn_inst [@CInline] let to: BM.bn_to_mont_st t_limbs n_limbs = BM.bn_to_mont bn_inst reduction [@CInline] let from: BM.bn_from_mont_st t_limbs n_limbs = BM.bn_from_mont bn_inst reduction // [@CInline] // let mont_mul: BM.bn_mont_mul_st t_limbs n_limbs = // BM.bn_mont_mul bn_inst reduction // [@CInline] // let mont_sqr: BM.bn_mont_sqr_st t_limbs n_limbs = // BM.bn_mont_sqr bn_inst reduction // inline_for_extraction noextract // instance mont_inst: BM.mont t_limbs = { // BM.bn = bn_inst; // BM.mont_check; // BM.precomp = precompr2; // BM.reduction; // BM.to; // BM.from; // BM.mul = mont_mul; // BM.sqr = mont_sqr; // } [@CInline] let areduction: AM.bn_almost_mont_reduction_st t_limbs n_limbs = AM.bn_almost_mont_reduction bn_inst [@CInline] let amont_mul: AM.bn_almost_mont_mul_st t_limbs n_limbs = AM.bn_almost_mont_mul bn_inst areduction [@CInline] let amont_sqr: AM.bn_almost_mont_sqr_st t_limbs n_limbs = AM.bn_almost_mont_sqr bn_inst areduction inline_for_extraction noextract instance almost_mont_inst: AM.almost_mont t_limbs = { AM.bn = bn_inst; AM.mont_check; AM.precomp = precompr2; AM.reduction = areduction; AM.to; AM.from; AM.mul = amont_mul; AM.sqr = amont_sqr; } [@CInline] let bn_slow_precomp : BR.bn_mod_slow_precomp_st t_limbs n_limbs = BR.bn_mod_slow_precomp almost_mont_inst let mod n a res = BS.mk_bn_mod_slow_safe n_limbs (BR.mk_bn_mod_slow n_limbs precompr2 bn_slow_precomp) n a res let exp_check: BE.bn_check_mod_exp_st t_limbs n_limbs = BE.bn_check_mod_exp n_limbs [@CInline] let exp_vartime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_vartime_precomp n_limbs (BE.bn_mod_exp_amm_bm_vartime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_vartime_precomp almost_mont_inst 4ul) [@CInline] let exp_consttime_precomp: BE.bn_mod_exp_precomp_st t_limbs n_limbs = BE.bn_mod_exp_consttime_precomp n_limbs (BE.bn_mod_exp_amm_bm_consttime_precomp almost_mont_inst) (BE.bn_mod_exp_amm_fw_consttime_precomp almost_mont_inst 4ul) [@CInline] let exp_vartime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_vartime_precomp [@CInline] let exp_consttime: BE.bn_mod_exp_st t_limbs n_limbs = BE.mk_bn_mod_exp n_limbs precompr2 exp_consttime_precomp let mod_exp_vartime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_vartime let mod_exp_consttime = BS.mk_bn_mod_exp_safe n_limbs exp_check exp_consttime let mod_inv_prime_vartime = BS.mk_bn_mod_inv_prime_safe n_limbs exp_vartime let mont_ctx_init r n = MA.bn_field_init n_limbs precompr2 r n let mont_ctx_free k = MA.bn_field_free k let mod_precomp k a res = BS.bn_mod_ctx n_limbs bn_slow_precomp k a res let mod_exp_vartime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_vartime_precomp k a bBits b res let mod_exp_consttime_precomp k a bBits b res = BS.mk_bn_mod_exp_ctx n_limbs exp_consttime_precomp k a bBits b res let mod_inv_prime_vartime_precomp k a res = BS.mk_bn_mod_inv_prime_ctx n_limbs (BI.mk_bn_mod_inv_prime_precomp n_limbs exp_vartime_precomp) k a res let new_bn_from_bytes_be = BS.new_bn_from_bytes_be let new_bn_from_bytes_le = BS.new_bn_from_bytes_le let bn_to_bytes_be = Hacl.Bignum.Convert.mk_bn_to_bytes_be true n_bytes
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.ModReduction.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum256_32.fst" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.ModReduction", "short_module": "BR" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.AlmostMontgomery", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Bignum.Convert.bn_to_bytes_le_st Hacl.Bignum256_32.t_limbs Hacl.Bignum256_32.n_bytes
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Convert.mk_bn_to_bytes_le", "Hacl.Bignum256_32.t_limbs", "Hacl.Bignum256_32.n_bytes" ]
[]
false
false
false
true
false
let bn_to_bytes_le =
Hacl.Bignum.Convert.mk_bn_to_bytes_le true n_bytes
false
SfLists.fst
SfLists.forallb
val forallb: l:ilist -> f:(int -> Tot bool) -> Tot bool
val forallb: l:ilist -> f:(int -> Tot bool) -> Tot bool
let rec forallb l f = match l with | Nil -> true | Cons x l' -> let b1 = f x in let b2 = forallb l' f in b1 && b2
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 245, "start_col": 0, "start_line": 240 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> () val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2) let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> () val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a let rec fold_left f l a = match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a) val app_cons: l:ilist -> hd:int -> tl:ilist -> Lemma (app l (Cons hd tl) = app (app l (Cons hd Nil)) (tl)) let rec app_cons l hd tl = match l with | Nil -> () | Cons hd' tl' -> let ih = app_cons tl' hd tl in () val snoc_app: l:ilist -> h:int -> Lemma (snoc l h = app l (Cons h Nil)) let rec snoc_app l h = match l with | Nil -> () | Cons hd tl -> let _ = snoc_app tl h in () val rev_app: tl:ilist -> hd:int -> Lemma (rev (Cons hd tl) = app (rev tl) (Cons hd Nil)) let rev_app tl hd = snoc_app (rev tl) hd val fold_left_cons_is_rev: l:ilist -> l':ilist -> Lemma (fold_left Cons l l' = app (rev l) l') let rec fold_left_cons_is_rev l l' = match l with | Nil -> () | Cons hd tl -> let _ = fold_left_cons_is_rev tl (Cons hd l') in let _ = app_cons (rev tl) hd l' in let _ = rev_app tl hd in () (*****)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> f: (_: Prims.int -> Prims.bool) -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.bool", "Prims.op_AmpAmp", "SfLists.forallb" ]
[ "recursion" ]
false
false
false
true
false
let rec forallb l f =
match l with | Nil -> true | Cons x l' -> let b1 = f x in let b2 = forallb l' f in b1 && b2
false
Hacl.Spec.K256.Field52.fst
Hacl.Spec.K256.Field52.fnegate5
val fnegate5 : _: Hacl.Spec.K256.Field52.Definitions.felem5 -> m: Lib.IntTypes.uint64 -> Hacl.Spec.K256.Field52.Definitions.felem5
let fnegate5 ((a0,a1,a2,a3,a4):felem5) (m:uint64) : felem5 = let r0 = u64 0xffffefffffc2f *. u64 2 *. m -. a0 in let r1 = u64 0xfffffffffffff *. u64 2 *. m -. a1 in let r2 = u64 0xfffffffffffff *. u64 2 *. m -. a2 in let r3 = u64 0xfffffffffffff *. u64 2 *. m -. a3 in let r4 = u64 0xffffffffffff *. u64 2 *. m -. a4 in (r0,r1,r2,r3,r4)
{ "file_name": "code/k256/Hacl.Spec.K256.Field52.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 260, "start_col": 0, "start_line": 254 }
module Hacl.Spec.K256.Field52 open FStar.Mul open Lib.IntTypes module S = Spec.K256 include Hacl.Spec.K256.Field52.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let load_felem5 ((s0,s1,s2,s3): felem4) : felem5 = let f0 = s0 &. mask52 in let f1 = (s0 >>. 52ul) |. ((s1 &. u64 0xffffffffff) <<. 12ul) in let f2 = (s1 >>. 40ul) |. ((s2 &. u64 0xfffffff) <<. 24ul) in let f3 = (s2 >>. 28ul) |. ((s3 &. u64 0xffff) <<. 36ul) in let f4 = s3 >>. 16ul in (f0,f1,f2,f3,f4) inline_for_extraction noextract let store_felem5 ((f0,f1,f2,f3,f4): felem5) : felem4 = let o0 = f0 |. (f1 <<. 52ul) in let o1 = (f1 >>. 12ul) |. (f2 <<. 40ul) in let o2 = (f2 >>. 24ul) |. (f3 <<. 28ul) in let o3 = (f3 >>. 36ul) |. (f4 <<. 16ul) in (o0,o1,o2,o3) inline_for_extraction noextract let add5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : felem5 = let o0 = a0 +. b0 in let o1 = a1 +. b1 in let o2 = a2 +. b2 in let o3 = a3 +. b3 in let o4 = a4 +. b4 in (o0,o1,o2,o3,o4) inline_for_extraction noextract let mul15 ((f0,f1,f2,f3,f4): felem5) (c:uint64) : felem5 = let o0 = f0 *. c in let o1 = f1 *. c in let o2 = f2 *. c in let o3 = f3 *. c in let o4 = f4 *. c in (o0,o1,o2,o3,o4) inline_for_extraction noextract let is_felem_zero_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL && u64_to_UInt64 f4 =. 0uL inline_for_extraction noextract let is_felem_ge_prime_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 f0 >=. 0xffffefffffc2fuL && u64_to_UInt64 f1 =. 0xfffffffffffffuL && u64_to_UInt64 f2 =. 0xfffffffffffffuL && u64_to_UInt64 f3 =. 0xfffffffffffffuL && u64_to_UInt64 f4 =. 0xffffffffffffuL inline_for_extraction noextract let is_felem_ge_prime5 ((t0,t1,t2,t3,t4): felem5) : uint64 = let m4 = eq_mask t4 mask48 in let m3 = eq_mask t3 mask52 in let m2 = eq_mask t2 mask52 in let m1 = eq_mask t1 mask52 in let m0 = gte_mask t0 (u64 0xffffefffffc2f) in let m = m0 &. m1 &. m2 &. m3 &. m4 in m inline_for_extraction noextract let is_felem_lt_prime_minus_order_vartime5 ((f0,f1,f2,f3,f4): felem5) : bool = let open Lib.RawIntTypes in if u64_to_UInt64 f4 >. 0uL then false else begin if u64_to_UInt64 f3 >. 0uL then false else begin if u64_to_UInt64 f2 <. 0x1455123uL then true else begin if u64_to_UInt64 f2 >. 0x1455123uL then false else begin if u64_to_UInt64 f1 <. 0x1950b75fc4402uL then true else begin if u64_to_UInt64 f1 >. 0x1950b75fc4402uL then false else u64_to_UInt64 f0 <. 0xda1722fc9baeeuL end end end end end inline_for_extraction noextract let is_felem_eq_vartime5 ((a0,a1,a2,a3,a4): felem5) ((b0,b1,b2,b3,b4): felem5) : bool = let open Lib.RawIntTypes in u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 && u64_to_UInt64 a2 =. u64_to_UInt64 b2 && u64_to_UInt64 a3 =. u64_to_UInt64 b3 && u64_to_UInt64 a4 =. u64_to_UInt64 b4 inline_for_extraction noextract let minus_x_mul_pow2_256 ((t0,t1,t2,t3,t4):felem5) : uint64 & felem5 = let x = t4 >>. 48ul in let t4 = t4 &. mask48 in x, (t0,t1,t2,t3,t4) inline_for_extraction noextract let carry_round5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let t1 = t1 +. (t0 >>. 52ul) in let t0 = t0 &. mask52 in let t2 = t2 +. (t1 >>. 52ul) in let t1 = t1 &. mask52 in let t3 = t3 +. (t2 >>. 52ul) in let t2 = t2 &. mask52 in let t4 = t4 +. (t3 >>. 52ul) in let t3 = t3 &. mask52 in (t0,t1,t2,t3,t4) inline_for_extraction noextract let plus_x_mul_pow2_256_minus_prime (x:uint64) ((t0,t1,t2,t3,t4):felem5) : felem5 = let t0 = t0 +. x *. u64 0x1000003D1 in carry_round5 (t0,t1,t2,t3,t4) inline_for_extraction noextract let normalize_weak5 ((t0,t1,t2,t3,t4):felem5) : felem5 = let x, (t0,t1,t2,t3,t4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in plus_x_mul_pow2_256_minus_prime x (t0,t1,t2,t3,t4) inline_for_extraction noextract let normalize5 ((f0,f1,f2,f3,f4):felem5) : felem5 = let (t0,t1,t2,t3,t4) = normalize_weak5 (f0,f1,f2,f3,f4) in let x, (r0,r1,r2,r3,r4) = minus_x_mul_pow2_256 (t0,t1,t2,t3,t4) in let is_ge_p_m = is_felem_ge_prime5 (r0,r1,r2,r3,r4) in // as_nat r >= S.prime let m_to_one = is_ge_p_m &. u64 1 in let x1 = m_to_one |. x in let (s0,s1,s2,s3,s4) = plus_x_mul_pow2_256_minus_prime x1 (r0,r1,r2,r3,r4) in let x2, (k0,k1,k2,k3,k4) = minus_x_mul_pow2_256 (s0,s1,s2,s3,s4) in (k0,k1,k2,k3,k4) inline_for_extraction noextract let fmul5 ((a0,a1,a2,a3,a4):felem5) ((b0,b1,b2,b3,b4):felem5) : felem5 = let r = u64 0x1000003D10 in let d0 = mul64_wide a0 b3 +. mul64_wide a1 b2 +. mul64_wide a2 b1 +. mul64_wide a3 b0 in let c0 = mul64_wide a4 b4 in let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in let d3 = d2 +. mul64_wide a0 b4 +. mul64_wide a1 b3 +. mul64_wide a2 b2 +. mul64_wide a3 b1 +. mul64_wide a4 b0 in let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in let c2 = mul64_wide a0 b0 in let d6 = d5 +. mul64_wide a1 b4 +. mul64_wide a2 b3 +. mul64_wide a3 b2 +. mul64_wide a4 b1 in let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in let u0' = tx |. (u0 <<. 4ul) in let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in let c5 = c4 +. mul64_wide a0 b1 +. mul64_wide a1 b0 in let d8 = d7 +. mul64_wide a2 b4 +. mul64_wide a3 b3 +. mul64_wide a4 b2 in let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in let c8 = c7 +. mul64_wide a0 b2 +. mul64_wide a1 b1 +. mul64_wide a2 b0 in let d10 = d9 +. mul64_wide a3 b4 +. mul64_wide a4 b3 in let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in let r4 = c12 +. t4' in (r0,r1,r2,r3,r4) inline_for_extraction noextract let fsqr5 ((a0,a1,a2,a3,a4):felem5) : felem5 = let r = u64 0x1000003D10 in let d0 = mul64_wide (a0 *. u64 2) a3 +. mul64_wide (a1 *. u64 2) a2 in let c0 = mul64_wide a4 a4 in let d1 = d0 +. mul64_wide r (to_u64 c0) in let c1 = to_u64 (c0 >>. 64ul) in let t3 = to_u64 d1 &. mask52 in let d2 = d1 >>. 52ul in let a4 = a4 *. u64 2 in let d3 = d2 +. mul64_wide a0 a4 +. mul64_wide (a1 *. u64 2) a3 +. mul64_wide a2 a2 in let d4 = d3 +. mul64_wide (r <<. 12ul) c1 in let t4 = to_u64 d4 &. mask52 in let d5 = d4 >>. 52ul in let tx = t4 >>. 48ul in let t4' = t4 &. mask48 in let c2 = mul64_wide a0 a0 in let d6 = d5 +. mul64_wide a1 a4 +. mul64_wide (a2 *. u64 2) a3 in let u0 = to_u64 d6 &. mask52 in let d7 = d6 >>. 52ul in let u0' = tx |. (u0 <<. 4ul) in let c3 = c2 +. mul64_wide u0' (r >>. 4ul) in let r0 = to_u64 c3 &. mask52 in let c4 = c3 >>. 52ul in let a0 = a0 *. u64 2 in let c5 = c4 +. mul64_wide a0 a1 in let d8 = d7 +. mul64_wide a2 a4 +. mul64_wide a3 a3 in let c6 = c5 +. mul64_wide (to_u64 d8 &. mask52) r in let d9 = d8 >>. 52ul in let r1 = to_u64 c6 &. mask52 in let c7 = c6 >>. 52ul in let c8 = c7 +. mul64_wide a0 a2 +. mul64_wide a1 a1 in let d10 = d9 +. mul64_wide a3 a4 in let c9 = c8 +. mul64_wide r (to_u64 d10) in let d11 = to_u64 (d10 >>. 64ul) in let r2 = to_u64 c9 &. mask52 in let c10 = c9 >>. 52ul in let c11 = c10 +. mul64_wide (r <<. 12ul) d11 +. to_u128 t3 in let r3 = to_u64 c11 &. mask52 in let c12 = to_u64 (c11 >>. 52ul) in let r4 = c12 +. t4' in (r0,r1,r2,r3,r4)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.K256.Field52.Definitions.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Field52.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Field52.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Spec.K256.Field52.Definitions.felem5 -> m: Lib.IntTypes.uint64 -> Hacl.Spec.K256.Field52.Definitions.felem5
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.K256.Field52.Definitions.felem5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.op_Star_Dot", "Lib.IntTypes.u64" ]
[]
false
false
false
true
false
let fnegate5 (a0, a1, a2, a3, a4: felem5) (m: uint64) : felem5 =
let r0 = u64 0xffffefffffc2f *. u64 2 *. m -. a0 in let r1 = u64 0xfffffffffffff *. u64 2 *. m -. a1 in let r2 = u64 0xfffffffffffff *. u64 2 *. m -. a2 in let r3 = u64 0xfffffffffffff *. u64 2 *. m -. a3 in let r4 = u64 0xffffffffffff *. u64 2 *. m -. a4 in (r0, r1, r2, r3, r4)
false
SfLists.fst
SfLists.existsb_existsb'
val existsb_existsb': l:ilist -> f:(int -> Tot bool) -> Lemma (ensures (existsb l f = existsb' l f))
val existsb_existsb': l:ilist -> f:(int -> Tot bool) -> Lemma (ensures (existsb l f = existsb' l f))
let rec existsb_existsb' l f = match l with | Nil -> () | Cons x l' -> let _ = existsb_existsb' l' f in ()
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 268, "start_col": 0, "start_line": 264 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> () val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2) let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> () val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a let rec fold_left f l a = match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a) val app_cons: l:ilist -> hd:int -> tl:ilist -> Lemma (app l (Cons hd tl) = app (app l (Cons hd Nil)) (tl)) let rec app_cons l hd tl = match l with | Nil -> () | Cons hd' tl' -> let ih = app_cons tl' hd tl in () val snoc_app: l:ilist -> h:int -> Lemma (snoc l h = app l (Cons h Nil)) let rec snoc_app l h = match l with | Nil -> () | Cons hd tl -> let _ = snoc_app tl h in () val rev_app: tl:ilist -> hd:int -> Lemma (rev (Cons hd tl) = app (rev tl) (Cons hd Nil)) let rev_app tl hd = snoc_app (rev tl) hd val fold_left_cons_is_rev: l:ilist -> l':ilist -> Lemma (fold_left Cons l l' = app (rev l) l') let rec fold_left_cons_is_rev l l' = match l with | Nil -> () | Cons hd tl -> let _ = fold_left_cons_is_rev tl (Cons hd l') in let _ = app_cons (rev tl) hd l' in let _ = rev_app tl hd in () (*****) val forallb: l:ilist -> f:(int -> Tot bool) -> Tot bool let rec forallb l f = match l with | Nil -> true | Cons x l' -> let b1 = f x in let b2 = forallb l' f in b1 && b2 val existsb: l:ilist -> f:(int -> Tot bool) -> Tot bool let rec existsb l f = match l with | Nil -> false | Cons x l' -> let b1 = f x in let b2 = existsb l' f in b1 || b2 val existsb': l:ilist -> f:(int -> Tot bool) -> Tot bool let existsb' l f = let g x = not (f x) in let b = forallb l g in not b (* this is a 4 star exercise in SF !*) val existsb_existsb': l:ilist -> f:(int -> Tot bool) -> Lemma
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> f: (_: Prims.int -> Prims.bool) -> FStar.Pervasives.Lemma (ensures SfLists.existsb l f = SfLists.existsb' l f)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.bool", "Prims.unit", "SfLists.existsb_existsb'" ]
[ "recursion" ]
false
false
true
false
false
let rec existsb_existsb' l f =
match l with | Nil -> () | Cons x l' -> let _ = existsb_existsb' l' f in ()
false
SfLists.fst
SfLists.fold_left
val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a
val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a
let rec fold_left f l a = match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a)
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 41, "end_line": 207, "start_col": 0, "start_line": 205 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> () val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2) let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
f: (_: Prims.int -> _: 'a -> 'a) -> l: SfLists.ilist -> a: 'a -> 'a
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "SfLists.ilist", "SfLists.fold_left" ]
[ "recursion" ]
false
false
false
true
false
let rec fold_left f l a =
match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a)
false
SfLists.fst
SfLists.existsb
val existsb: l:ilist -> f:(int -> Tot bool) -> Tot bool
val existsb: l:ilist -> f:(int -> Tot bool) -> Tot bool
let rec existsb l f = match l with | Nil -> false | Cons x l' -> let b1 = f x in let b2 = existsb l' f in b1 || b2
{ "file_name": "examples/software_foundations/SfLists.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 253, "start_col": 0, "start_line": 248 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A translation to F* of Lists.v from Software Foundations Original name: "Lists: Working with Structured Data" *) (* Lists of Numbers *) module SfLists type ilist = | Nil : ilist | Cons : int -> ilist -> ilist val length : ilist -> Tot nat let rec length l = match l with | Nil -> 0 | Cons h t -> length t + 1 val repeat : int -> count:nat -> Tot ilist let rec repeat n count = match count with | 0 -> Nil | _ -> Cons n (repeat n (count - 1)) val app : ilist -> ilist -> Tot ilist let rec app l1 l2 = match l1 with | Nil -> l2 | Cons h t -> Cons h (app t l2) val test_app1 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) (Cons 4 (Cons 5 Nil)) = (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil))))))) let test_app1 () = () val test_app2 : unit -> Lemma (ensures (app Nil (Cons 4 (Cons 5 Nil)) = (Cons 4 (Cons 5 Nil)))) let test_app2 () = () val test_app3 : unit -> Lemma (ensures (app (Cons 1 (Cons 2 (Cons 3 Nil))) Nil) = (Cons 1 (Cons 2 (Cons 3 Nil)))) let test_app3 () = () val nil_app : l:ilist -> Lemma (ensures (app Nil l = l)) let nil_app l = () val app_nil : l:ilist -> Lemma (ensures (app l Nil = l)) let rec app_nil l = match l with | Nil -> () | Cons h t -> app_nil t val hd : l:ilist{l =!= Nil} -> Tot int let hd l = match l with | Cons h t -> h (* In SF they have tl Nil = nil, but we do better below *) val tl_strange : l:ilist -> Tot ilist let tl_strange l = match l with | Nil -> Nil | Cons h t -> t val tl_strange_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred l = () val tl_strange_length_pred_equiv : l:ilist{Cons? l} -> Lemma (ensures ((length l) - 1 = length (tl_strange l))) let tl_strange_length_pred_equiv l = () val tl : l:ilist{l =!= Nil} -> Tot ilist let tl l = match l with | Cons h t -> t val tl_length_pred : l:ilist{l =!= Nil} -> Lemma (ensures ((length l) - 1 = length (tl l))) let tl_length_pred l = () val app_assoc : l1 : ilist -> l2 : ilist -> l3 : ilist -> Lemma (ensures (app (app l1 l2) l3) = app l1 (app l2 l3)) let rec app_assoc l1 l2 l3 = match l1 with | Nil -> () | Cons h t -> app_assoc t l2 l3 val app_length : l1 : ilist -> l2 : ilist -> Lemma (ensures (length (app l1 l2) = (length l1) + (length l2))) let rec app_length l1 l2 = match l1 with | Nil -> () | Cons x1 l1' -> app_length l1' l2 val snoc : ilist -> int -> Tot ilist let rec snoc l v = match l with | Nil -> Cons v Nil | Cons h t -> Cons h (snoc t v) val rev : ilist -> Tot ilist let rec rev l = match l with | Nil -> Nil | Cons h t -> snoc (rev t) h val length_snoc : n : int -> l : ilist -> Lemma (ensures (length (snoc l n) = length l + 1)) let rec length_snoc n l = match l with | Nil -> () | Cons h t -> length_snoc n t val rev_length : l : ilist -> Lemma (ensures (length (rev l) = length l)) let rec rev_length l = match l with | Nil -> () | Cons h t -> length_snoc h (rev t); rev_length t val foo1 : n:int -> l : ilist -> Pure unit (requires (b2t (repeat n 0 = l))) (ensures (fun r -> length l = 0)) let foo1 n l = () val foo2 : n : nat -> m : nat -> l : ilist -> Pure unit (requires (b2t (repeat n m = l))) (ensures (fun r -> length l = m)) let rec foo2 n m l = match m with | 0 -> () | _ -> foo2 n (m-1) (repeat n (m-1)) val foo3 : l : ilist -> n : int -> m : nat -> Pure unit (requires (b2t (length l = m))) (ensures (fun r -> (length (snoc l n) = m+1))) let rec foo3 l n m = match l with | Nil -> () | Cons h t -> foo3 t n (length t) val foo4 : n : int -> l1 : ilist -> l2 : ilist -> Pure unit (requires (b2t (snoc l1 n = l2))) (ensures (fun r -> 0 < length l2)) let foo4 n l1 l2 = () val snoc_cons: l:ilist -> h:int -> Lemma (rev (snoc l h) = Cons h (rev l)) let rec snoc_cons l h = match l with | Nil -> () | Cons hd tl -> let ih = snoc_cons tl h in () val rev_involutive: l:ilist -> Lemma (rev (rev l) = l) let rec rev_involutive l = match l with | Nil -> () | Cons h t -> let ih = rev_involutive t in let lem = snoc_cons (rev t) h in () val snoc_injective: l1:ilist -> h1:int -> l2:ilist -> h2:int -> Lemma (snoc l1 h1 = snoc l2 h2 ==> l1 = l2 /\ h1 = h2) let rec snoc_injective l1 h1 l2 h2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = snoc_injective tl1 h1 tl2 h2 in () | _, _ -> () val rev_injective: l1:ilist -> l2:ilist -> Lemma (rev l1 = rev l2 ==> l1 = l2) let rec rev_injective l1 l2 = match (l1, l2) with | Nil, Nil -> () | Cons hd1 tl1, Cons hd2 tl2 -> let ih = rev_injective tl1 tl2 in let lem = snoc_injective (rev tl1) hd1 (rev tl2) hd2 in () | _, _ -> () val fold_left: f:(int -> 'a -> Tot 'a) -> l:ilist -> 'a -> Tot 'a let rec fold_left f l a = match l with | Nil -> a | Cons hd tl -> fold_left f tl (f hd a) val app_cons: l:ilist -> hd:int -> tl:ilist -> Lemma (app l (Cons hd tl) = app (app l (Cons hd Nil)) (tl)) let rec app_cons l hd tl = match l with | Nil -> () | Cons hd' tl' -> let ih = app_cons tl' hd tl in () val snoc_app: l:ilist -> h:int -> Lemma (snoc l h = app l (Cons h Nil)) let rec snoc_app l h = match l with | Nil -> () | Cons hd tl -> let _ = snoc_app tl h in () val rev_app: tl:ilist -> hd:int -> Lemma (rev (Cons hd tl) = app (rev tl) (Cons hd Nil)) let rev_app tl hd = snoc_app (rev tl) hd val fold_left_cons_is_rev: l:ilist -> l':ilist -> Lemma (fold_left Cons l l' = app (rev l) l') let rec fold_left_cons_is_rev l l' = match l with | Nil -> () | Cons hd tl -> let _ = fold_left_cons_is_rev tl (Cons hd l') in let _ = app_cons (rev tl) hd l' in let _ = rev_app tl hd in () (*****) val forallb: l:ilist -> f:(int -> Tot bool) -> Tot bool let rec forallb l f = match l with | Nil -> true | Cons x l' -> let b1 = f x in let b2 = forallb l' f in b1 && b2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SfLists.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: SfLists.ilist -> f: (_: Prims.int -> Prims.bool) -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "SfLists.ilist", "Prims.int", "Prims.bool", "Prims.op_BarBar", "SfLists.existsb" ]
[ "recursion" ]
false
false
false
true
false
let rec existsb l f =
match l with | Nil -> false | Cons x l' -> let b1 = f x in let b2 = existsb l' f in b1 || b2
false