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
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.malloc_224
val malloc_224 : Hacl.Streaming.Functor.malloc_st Hacl.Streaming.SHA2.hacl_sha2_224 () (Stateful?.s Hacl.Streaming.SHA2.state_224 ()) (FStar.Ghost.erased Prims.unit)
let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 129, "start_col": 0, "start_line": 129 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.malloc_st Hacl.Streaming.SHA2.hacl_sha2_224 () (Stateful?.s Hacl.Streaming.SHA2.state_224 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.malloc", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_224", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_224", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let malloc_224 =
F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.lt_nat
val lt_nat (n1 n2: nat) : Tot bool
val lt_nat (n1 n2: nat) : Tot bool
let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 34, "start_col": 0, "start_line": 34 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
n1: Prims.nat -> n2: Prims.nat -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_LessThan", "Prims.bool" ]
[]
false
false
false
true
false
let lt_nat (n1 n2: nat) : Tot bool =
n1 < n2
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.alloca_224
val alloca_224 : Hacl.Streaming.Functor.alloca_st Hacl.Streaming.SHA2.hacl_sha2_224 () (Stateful?.s Hacl.Streaming.SHA2.state_224 ()) (FStar.Ghost.erased Prims.unit)
let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 128, "start_col": 0, "start_line": 128 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // --------
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.alloca_st Hacl.Streaming.SHA2.hacl_sha2_224 () (Stateful?.s Hacl.Streaming.SHA2.state_224 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.alloca", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_224", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_224", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let alloca_224 =
F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.prog
val prog : Type0
let prog = list instr
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 50, "start_col": 0, "start_line": 50 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "StackMachine.instr" ]
[]
false
false
false
true
true
let prog =
list instr
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.digest_256
val digest_256 : Hacl.Streaming.Functor.digest_st Hacl.Streaming.SHA2.hacl_sha2_256 () (Stateful?.s Hacl.Streaming.SHA2.state_256 ()) (FStar.Ghost.erased Prims.unit)
let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 101, "start_col": 0, "start_line": 101 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.digest_st Hacl.Streaming.SHA2.hacl_sha2_256 () (Stateful?.s Hacl.Streaming.SHA2.state_256 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.digest", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_256", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_256", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let digest_256 =
F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.reset_224
val reset_224 : Hacl.Streaming.Functor.reset_st Hacl.Streaming.SHA2.hacl_sha2_224 (FStar.Ghost.hide (FStar.Ghost.reveal (FStar.Ghost.hide ()))) (Stateful?.s Hacl.Streaming.SHA2.state_224 ()) (FStar.Ghost.erased Prims.unit)
let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 82, "end_line": 130, "start_col": 0, "start_line": 130 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.reset_st Hacl.Streaming.SHA2.hacl_sha2_224 (FStar.Ghost.hide (FStar.Ghost.reveal (FStar.Ghost.hide ()))) (Stateful?.s Hacl.Streaming.SHA2.state_224 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.reset", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_224", "FStar.Ghost.hide", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_224", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let reset_224 =
F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.add_nat
val add_nat (n1 n2: nat) : Tot nat
val add_nat (n1 n2: nat) : Tot nat
let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 30, "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. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
n1: Prims.nat -> n2: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Addition" ]
[]
false
false
false
true
false
let add_nat (n1 n2: nat) : Tot nat =
n1 + n2
false
StackMachine.fst
StackMachine.mul_nat
val mul_nat (n1 n2: nat) : Tot nat
val mul_nat (n1 n2: nat) : Tot nat
let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 31, "start_col": 0, "start_line": 31 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
n1: Prims.nat -> n2: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Multiply" ]
[]
false
false
false
true
false
let mul_nat (n1 n2: nat) : Tot nat =
n1 `op_Multiply` n2
false
StackMachine.fst
StackMachine.stack
val stack : Type0
let stack = list nat
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 51, "start_col": 0, "start_line": 51 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Prims.nat" ]
[]
false
false
false
true
true
let stack =
list nat
false
StackMachine.fst
StackMachine.eq_nat
val eq_nat (n1 n2: nat) : Tot bool
val eq_nat (n1 n2: nat) : Tot bool
let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 32, "start_col": 0, "start_line": 32 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
n1: Prims.nat -> n2: Prims.nat -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Equality", "Prims.bool" ]
[]
false
false
false
true
false
let eq_nat (n1 n2: nat) : Tot bool =
n1 = n2
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.update_224_256
val update_224_256 : Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_256 (FStar.Ghost.reveal (FStar.Ghost.hide ())) (Stateful?.s Hacl.Streaming.SHA2.state_256 ()) (FStar.Ghost.erased Prims.unit)
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 88, "end_line": 85, "start_col": 0, "start_line": 85 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ]
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_256 (FStar.Ghost.reveal (FStar.Ghost.hide ())) (Stateful?.s Hacl.Streaming.SHA2.state_256 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.update", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_256", "FStar.Ghost.hide", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_256", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let update_224_256 =
F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.alloca_512
val alloca_512 : Hacl.Streaming.Functor.alloca_st Hacl.Streaming.SHA2.hacl_sha2_512 () (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 160, "start_col": 0, "start_line": 160 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // --------
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.alloca_st Hacl.Streaming.SHA2.hacl_sha2_512 () (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.alloca", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let alloca_512 =
F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.tstack
val tstack : Type0
let tstack = list typ
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 133, "start_col": 0, "start_line": 133 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "StackMachine.typ" ]
[]
false
false
false
true
true
let tstack =
list typ
false
StackMachine.fst
StackMachine.binopDenote
val binopDenote: b: binop -> nat -> nat -> Tot nat
val binopDenote: b: binop -> nat -> nat -> Tot nat
let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "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. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: StackMachine.binop -> _: Prims.nat -> _: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "StackMachine.binop", "StackMachine.add_nat", "StackMachine.mul_nat", "Prims.nat" ]
[]
false
false
false
true
false
let binopDenote (b: binop) : nat -> nat -> Tot nat =
match b with | Plus -> add_nat | Times -> mul_nat
false
StackMachine.fst
StackMachine.expDenote
val expDenote (e: exp) : Tot nat
val expDenote (e: exp) : Tot nat
let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2)
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 44, "start_col": 0, "start_line": 41 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
e: StackMachine.exp -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "StackMachine.exp", "Prims.nat", "StackMachine.binop", "StackMachine.binopDenote", "StackMachine.expDenote" ]
[ "recursion" ]
false
false
false
true
false
let rec expDenote (e: exp) : Tot nat =
match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.malloc_512
val malloc_512 : Hacl.Streaming.Functor.malloc_st Hacl.Streaming.SHA2.hacl_sha2_512 () (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 161, "start_col": 0, "start_line": 161 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.malloc_st Hacl.Streaming.SHA2.hacl_sha2_512 () (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.malloc", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let malloc_512 =
F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.compile
val compile (e: exp) : Tot prog
val compile (e: exp) : Tot prog
let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b]
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 72, "start_col": 0, "start_line": 69 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
e: StackMachine.exp -> StackMachine.prog
Prims.Tot
[ "total" ]
[]
[ "StackMachine.exp", "Prims.nat", "Prims.Cons", "StackMachine.instr", "StackMachine.IConst", "Prims.Nil", "StackMachine.binop", "FStar.List.Tot.Base.op_At", "StackMachine.compile", "StackMachine.IBinop", "StackMachine.prog" ]
[ "recursion" ]
false
false
false
true
false
let rec compile (e: exp) : Tot prog =
match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b]
false
StackMachine.fst
StackMachine.progDenote
val progDenote (p: prog) (s: stack) : Tot (option stack)
val progDenote (p: prog) (s: stack) : Tot (option stack)
let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s'
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 67, "start_col": 0, "start_line": 61 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: StackMachine.prog -> s: StackMachine.stack -> FStar.Pervasives.Native.option StackMachine.stack
Prims.Tot
[ "total" ]
[]
[ "StackMachine.prog", "StackMachine.stack", "FStar.Pervasives.Native.Some", "StackMachine.instr", "Prims.list", "StackMachine.instrDenote", "FStar.Pervasives.Native.None", "StackMachine.progDenote", "FStar.Pervasives.Native.option" ]
[ "recursion" ]
false
false
false
true
false
let rec progDenote (p: prog) (s: stack) : Tot (option stack) =
match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s'
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.reset_384
val reset_384 : Hacl.Streaming.Functor.reset_st Hacl.Streaming.SHA2.hacl_sha2_384 (FStar.Ghost.hide (FStar.Ghost.reveal (FStar.Ghost.hide ()))) (Stateful?.s Hacl.Streaming.SHA2.state_384 ()) (FStar.Ghost.erased Prims.unit)
let reset_384 = F.reset hacl_sha2_384 (G.hide ()) (state_384.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 82, "end_line": 219, "start_col": 0, "start_line": 219 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_512`. This function is identical to the free function for SHA2_384."; ] let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 64 bytes."] val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 let hash_512 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-384 // -------- inline_for_extraction noextract let alloca_384 = F.alloca hacl_sha2_384 () (state_384.s ()) (G.erased unit)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.reset_st Hacl.Streaming.SHA2.hacl_sha2_384 (FStar.Ghost.hide (FStar.Ghost.reveal (FStar.Ghost.hide ()))) (Stateful?.s Hacl.Streaming.SHA2.state_384 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.reset", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_384", "FStar.Ghost.hide", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_384", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let reset_384 =
F.reset hacl_sha2_384 (G.hide ()) (state_384.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.compile_correct
val compile_correct (e: _) : Lemma (progDenote (compile e) [] = Some [expDenote e])
val compile_correct (e: _) : Lemma (progDenote (compile e) [] = Some [expDenote e])
let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] []
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 96, "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. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
e: StackMachine.exp -> FStar.Pervasives.Lemma (ensures StackMachine.progDenote (StackMachine.compile e) [] = FStar.Pervasives.Native.Some [StackMachine.expDenote e])
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "StackMachine.exp", "StackMachine.compile_correct'", "Prims.Nil", "StackMachine.instr", "Prims.nat", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.b2t", "Prims.op_Equality", "FStar.Pervasives.Native.option", "StackMachine.stack", "StackMachine.progDenote", "StackMachine.compile", "FStar.Pervasives.Native.Some", "Prims.Cons", "StackMachine.expDenote", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) =
compile_correct' e [] []
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.free_224
val free_224:F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit)
val free_224:F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 112, "end_line": 139, "start_col": 0, "start_line": 139 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."]
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.free_st Hacl.Streaming.SHA2.hacl_sha2_256 () (Stateful?.s Hacl.Streaming.SHA2.state_256 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.state", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_256", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_256", "FStar.Ghost.erased", "Hacl.Streaming.SHA2.free_256" ]
[]
false
false
false
false
false
let free_224:F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) =
fun state -> free_256 state
false
StackMachine.fst
StackMachine.app_nil_end
val app_nil_end (#a: Type) (l: list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])]
val app_nil_end (#a: Type) (l: list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])]
let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l'
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 93, "start_col": 0, "start_line": 89 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.list a -> FStar.Pervasives.Lemma (ensures l == l @ []) (decreases l) [SMTPat (l @ [])]
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.list", "StackMachine.app_nil_end", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.op_At", "Prims.Nil", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat" ]
[ "recursion" ]
false
false
true
false
false
let rec app_nil_end (#a: Type) (l: list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] =
match l with | [] -> () | _ :: l' -> app_nil_end l'
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.malloc_384
val malloc_384 : Hacl.Streaming.Functor.malloc_st Hacl.Streaming.SHA2.hacl_sha2_384 () (Stateful?.s Hacl.Streaming.SHA2.state_384 ()) (FStar.Ghost.erased Prims.unit)
let malloc_384 = F.malloc hacl_sha2_384 () (state_384.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 218, "start_col": 0, "start_line": 218 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_512`. This function is identical to the free function for SHA2_384."; ] let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 64 bytes."] val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 let hash_512 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-384 // -------- inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.malloc_st Hacl.Streaming.SHA2.hacl_sha2_384 () (Stateful?.s Hacl.Streaming.SHA2.state_384 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.malloc", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_384", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_384", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let malloc_384 =
F.malloc hacl_sha2_384 () (state_384.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.tcompile_correct
val tcompile_correct (#t: _) (e: texp t) : Lemma (tprogDenote (tcompile e []) () == (texpDenote e, ()))
val tcompile_correct (#t: _) (e: texp t) : Lemma (tprogDenote (tcompile e []) () == (texpDenote e, ()))
let tcompile_correct #t (e : texp t) : Lemma (tprogDenote (tcompile e []) () == (texpDenote e, ())) = tcompile_correct' e [] ()
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 225, "start_col": 0, "start_line": 223 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2) let tstack = list typ type tinstr : tstack -> tstack -> Type0 = | TiNConst : s:tstack -> nat -> tinstr s (Nat :: s) | TiBConst : s:tstack -> bool -> tinstr s (Bool :: s) | TiBinop : #arg1:typ -> #arg2:typ -> #res:typ -> #s:tstack -> tbinop arg1 arg2 res -> tinstr (arg1 :: arg2 :: s) (res :: s) type tprog : tstack -> tstack -> Type0 = | TNil : #s:tstack -> tprog s s | TCons : #s1:tstack -> #s2:tstack -> #s3:tstack -> tinstr s1 s2 -> tprog s2 s3 -> tprog s1 s3 let rec vstack (ts : tstack) : Type0 = match ts with | [] -> unit | t :: ts' -> typeDenote t * vstack ts' let rec tinstrDenote (#ts:tstack) (#ts':tstack) (i : tinstr ts ts') (s:vstack ts) : Tot (vstack ts') = match i with | TiNConst _ n -> (n, s) | TiBConst _ b -> (b, s) | TiBinop #targ1 #targ2 #tres #tss b -> (* Take 1 *) (* let (arg1, (arg2, s')) = s in *) (* ((tbinopDenote b) arg1 arg2, s') *) (* Implicit pattern variables in (Prims.Mktuple2 arg1 (Prims.Mktuple2 arg2 s')) *) (* could not be resolved against expected type (StackMachine.vstack ts); *) (* Variables {?63598, ?63596, ?63406} were unresolved; please bind them explicitly *) (* Take 2 *) (* ((tbinopDenote b) (fst s) (fst (snd s)), (snd (snd s))) *) (* Subtyping check failed; expected type *) (* (Prims.tuple2 (?63342 ts ts' i s uu___ uu___ uu___ uu___ b) *) (* (?63343 ts ts' i s uu___ uu___ uu___ uu___ b)); *) (* got type (StackMachine.vstack ts) *) (* Take 3: fully annotated *) let s' : typeDenote targ1 * (typeDenote targ2 * vstack tss) = s in let (arg1, (arg2, s'')) = s' in (((tbinopDenote b) arg1 arg2, s'') <: (typeDenote tres * vstack tss)) let rec tprogDenote #ts #ts' (p : tprog ts ts') (s:vstack ts) : Tot (vstack ts') (decreases p) = match p with | TNil -> s | TCons i p' -> tprogDenote p' (tinstrDenote i s) let rec tconcat #ts #ts' #ts'' (p : tprog ts ts') (p' : tprog ts' ts'') : Tot (tprog ts ts'') (decreases p) = match p with | TNil -> p' | TCons i p1 -> TCons i (tconcat p1 p') let rec tcompile #t (e : texp t) (ts : tstack) : Tot (tprog ts (t :: ts)) (decreases e) = match e with | TNConst n -> TCons (TiNConst _ n) TNil | TBConst b -> TCons (TiBConst _ b) TNil | TBinop #t1 #t2 #t b e1 e2 -> tconcat (tcompile e2 _) (tconcat (tcompile e1 _) (TCons (TiBinop b) TNil)) #reset-options "--z3rlimit 10" let rec tconcat_correct #ts #ts' #ts'' (p : tprog ts ts') (p' : tprog ts' ts'') (s : vstack ts) : Lemma (requires True) (ensures (tprogDenote (tconcat p p') s == tprogDenote p' (tprogDenote p s))) (decreases p) [SMTPat (tprogDenote (tconcat p p') s)] = match p with | TNil -> () | TCons t pp -> tconcat_correct pp p' (tinstrDenote t s) (* again just taking Adam's instantiations *) let rec tcompile_correct' #t (e : texp t) ts (s : vstack ts) : Lemma (requires True) (ensures (tprogDenote (tcompile e ts) s == (texpDenote e, s))) (decreases e) = match e with | TNConst _ -> () | TBConst _ -> () | TBinop #t1 #t2 b e1 e2 -> tcompile_correct' e1 (t2 :: ts) (texpDenote e2, s); tcompile_correct' e2 ts s; let p1 = tcompile e1 (t1::ts) in let p = TCons (TiBinop b) TNil in tconcat_correct p1 p (texpDenote e2, s) //NS: added this explicitly after #1028 (* again just taking Adam's instantiations *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: StackMachine.texp t -> FStar.Pervasives.Lemma (ensures StackMachine.tprogDenote (StackMachine.tcompile e []) () == (StackMachine.texpDenote e, ()))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "StackMachine.typ", "StackMachine.texp", "StackMachine.tcompile_correct'", "Prims.Nil", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "StackMachine.typeDenote", "StackMachine.vstack", "StackMachine.tprogDenote", "Prims.Cons", "StackMachine.tcompile", "FStar.Pervasives.Native.Mktuple2", "StackMachine.texpDenote", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let tcompile_correct #t (e: texp t) : Lemma (tprogDenote (tcompile e []) () == (texpDenote e, ())) =
tcompile_correct' e [] ()
false
StackMachine.fst
StackMachine.app_assoc_reverse
val app_assoc_reverse (#a: Type) (l m n: list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)]
val app_assoc_reverse (#a: Type) (l m n: list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)]
let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 78, "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. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.list a -> m: Prims.list a -> n: Prims.list a -> FStar.Pervasives.Lemma (ensures (l @ m) @ n == l @ m @ n) [SMTPat ((l @ m) @ n)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "StackMachine.app_assoc_reverse", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.op_At", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[ "recursion" ]
false
false
true
false
false
let rec app_assoc_reverse (#a: Type) (l m n: list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] =
match l with | [] -> () | _ :: l' -> app_assoc_reverse l' m n
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.copy_512
val copy_512 : Hacl.Streaming.Functor.copy_st Hacl.Streaming.SHA2.hacl_sha2_512 (FStar.Ghost.reveal (FStar.Ghost.hide ())) (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 168, "start_col": 0, "start_line": 168 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.copy_st Hacl.Streaming.SHA2.hacl_sha2_512 (FStar.Ghost.reveal (FStar.Ghost.hide ())) (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.copy", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "FStar.Ghost.hide", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let copy_512 =
F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.compile_correct'
val compile_correct' (e p s: _) : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s))
val compile_correct' (e p s: _) : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s))
let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 74, "end_line": 85, "start_col": 0, "start_line": 80 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
e: StackMachine.exp -> p: Prims.list StackMachine.instr -> s: Prims.list Prims.nat -> FStar.Pervasives.Lemma (ensures StackMachine.progDenote (StackMachine.compile e @ p) s = StackMachine.progDenote p (StackMachine.expDenote e :: s))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "StackMachine.exp", "Prims.list", "StackMachine.instr", "Prims.nat", "StackMachine.binop", "StackMachine.compile_correct'", "FStar.List.Tot.Base.op_At", "StackMachine.compile", "Prims.Cons", "StackMachine.IBinop", "Prims.Nil", "Prims.unit", "StackMachine.expDenote", "Prims.l_True", "Prims.squash", "Prims.b2t", "Prims.op_Equality", "FStar.Pervasives.Native.option", "StackMachine.stack", "StackMachine.progDenote", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) =
match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 :: s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.alloca_384
val alloca_384 : Hacl.Streaming.Functor.alloca_st Hacl.Streaming.SHA2.hacl_sha2_384 () (Stateful?.s Hacl.Streaming.SHA2.state_384 ()) (FStar.Ghost.erased Prims.unit)
let alloca_384 = F.alloca hacl_sha2_384 () (state_384.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 217, "start_col": 0, "start_line": 217 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_512`. This function is identical to the free function for SHA2_384."; ] let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 64 bytes."] val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 let hash_512 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-384 // --------
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.alloca_st Hacl.Streaming.SHA2.hacl_sha2_384 () (Stateful?.s Hacl.Streaming.SHA2.state_384 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.alloca", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_384", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_384", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let alloca_384 =
F.alloca hacl_sha2_384 () (state_384.s ()) (G.erased unit)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.update_384_512
val update_384_512 : Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_512 (FStar.Ghost.reveal (FStar.Ghost.hide ())) (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 88, "end_line": 174, "start_col": 0, "start_line": 174 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ]
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_512 (FStar.Ghost.reveal (FStar.Ghost.hide ())) (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.update", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "FStar.Ghost.hide", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let update_384_512 =
F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.tbinopDenote
val tbinopDenote: #arg1: _ -> #arg2: _ -> #res: _ -> b: tbinop arg1 arg2 res -> typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res)
val tbinopDenote: #arg1: _ -> #arg2: _ -> #res: _ -> b: tbinop arg1 arg2 res -> typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res)
let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 125, "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. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: StackMachine.tbinop arg1 arg2 res -> _: StackMachine.typeDenote arg1 -> _: StackMachine.typeDenote arg2 -> StackMachine.typeDenote res
Prims.Tot
[ "total" ]
[]
[ "StackMachine.typ", "StackMachine.tbinop", "StackMachine.add_nat", "StackMachine.mul_nat", "StackMachine.eq_nat", "StackMachine.eq_bool", "StackMachine.lt_nat", "StackMachine.typeDenote" ]
[]
false
false
false
false
false
let tbinopDenote #arg1 #arg2 #res (b: tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) =
match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat
false
StackMachine.fst
StackMachine.texpDenote
val texpDenote (#t: _) (e: texp t) : Tot (typeDenote t) (decreases e)
val texpDenote (#t: _) (e: texp t) : Tot (typeDenote t) (decreases e)
let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2)
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 72, "end_line": 131, "start_col": 0, "start_line": 127 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
e: StackMachine.texp t -> Prims.Tot (StackMachine.typeDenote t)
Prims.Tot
[ "total", "" ]
[]
[ "StackMachine.typ", "StackMachine.texp", "Prims.nat", "Prims.bool", "StackMachine.tbinop", "StackMachine.tbinopDenote", "StackMachine.texpDenote", "StackMachine.typeDenote" ]
[ "recursion" ]
false
false
false
false
false
let rec texpDenote #t (e: texp t) : Tot (typeDenote t) (decreases e) =
match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2)
false
StackMachine.fst
StackMachine.vstack
val vstack (ts: tstack) : Type0
val vstack (ts: tstack) : Type0
let rec vstack (ts : tstack) : Type0 = match ts with | [] -> unit | t :: ts' -> typeDenote t * vstack ts'
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 149, "start_col": 0, "start_line": 146 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2) let tstack = list typ type tinstr : tstack -> tstack -> Type0 = | TiNConst : s:tstack -> nat -> tinstr s (Nat :: s) | TiBConst : s:tstack -> bool -> tinstr s (Bool :: s) | TiBinop : #arg1:typ -> #arg2:typ -> #res:typ -> #s:tstack -> tbinop arg1 arg2 res -> tinstr (arg1 :: arg2 :: s) (res :: s) type tprog : tstack -> tstack -> Type0 = | TNil : #s:tstack -> tprog s s | TCons : #s1:tstack -> #s2:tstack -> #s3:tstack -> tinstr s1 s2 -> tprog s2 s3 -> tprog s1 s3
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
ts: StackMachine.tstack -> Type0
Prims.Tot
[ "total" ]
[]
[ "StackMachine.tstack", "Prims.unit", "StackMachine.typ", "Prims.list", "FStar.Pervasives.Native.tuple2", "StackMachine.typeDenote", "StackMachine.vstack" ]
[ "recursion" ]
false
false
false
true
true
let rec vstack (ts: tstack) : Type0 =
match ts with | [] -> unit | t :: ts' -> typeDenote t * vstack ts'
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.digest_512
val digest_512 : Hacl.Streaming.Functor.digest_st Hacl.Streaming.SHA2.hacl_sha2_512 () (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 189, "start_col": 0, "start_line": 189 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.digest_st Hacl.Streaming.SHA2.hacl_sha2_512 () (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.digest", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let digest_512 =
F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.tprogDenote
val tprogDenote (#ts #ts': _) (p: tprog ts ts') (s: vstack ts) : Tot (vstack ts') (decreases p)
val tprogDenote (#ts #ts': _) (p: tprog ts ts') (s: vstack ts) : Tot (vstack ts') (decreases p)
let rec tprogDenote #ts #ts' (p : tprog ts ts') (s:vstack ts) : Tot (vstack ts') (decreases p) = match p with | TNil -> s | TCons i p' -> tprogDenote p' (tinstrDenote i s)
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 180, "start_col": 0, "start_line": 176 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2) let tstack = list typ type tinstr : tstack -> tstack -> Type0 = | TiNConst : s:tstack -> nat -> tinstr s (Nat :: s) | TiBConst : s:tstack -> bool -> tinstr s (Bool :: s) | TiBinop : #arg1:typ -> #arg2:typ -> #res:typ -> #s:tstack -> tbinop arg1 arg2 res -> tinstr (arg1 :: arg2 :: s) (res :: s) type tprog : tstack -> tstack -> Type0 = | TNil : #s:tstack -> tprog s s | TCons : #s1:tstack -> #s2:tstack -> #s3:tstack -> tinstr s1 s2 -> tprog s2 s3 -> tprog s1 s3 let rec vstack (ts : tstack) : Type0 = match ts with | [] -> unit | t :: ts' -> typeDenote t * vstack ts' let rec tinstrDenote (#ts:tstack) (#ts':tstack) (i : tinstr ts ts') (s:vstack ts) : Tot (vstack ts') = match i with | TiNConst _ n -> (n, s) | TiBConst _ b -> (b, s) | TiBinop #targ1 #targ2 #tres #tss b -> (* Take 1 *) (* let (arg1, (arg2, s')) = s in *) (* ((tbinopDenote b) arg1 arg2, s') *) (* Implicit pattern variables in (Prims.Mktuple2 arg1 (Prims.Mktuple2 arg2 s')) *) (* could not be resolved against expected type (StackMachine.vstack ts); *) (* Variables {?63598, ?63596, ?63406} were unresolved; please bind them explicitly *) (* Take 2 *) (* ((tbinopDenote b) (fst s) (fst (snd s)), (snd (snd s))) *) (* Subtyping check failed; expected type *) (* (Prims.tuple2 (?63342 ts ts' i s uu___ uu___ uu___ uu___ b) *) (* (?63343 ts ts' i s uu___ uu___ uu___ uu___ b)); *) (* got type (StackMachine.vstack ts) *) (* Take 3: fully annotated *) let s' : typeDenote targ1 * (typeDenote targ2 * vstack tss) = s in let (arg1, (arg2, s'')) = s' in (((tbinopDenote b) arg1 arg2, s'') <: (typeDenote tres * vstack tss))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: StackMachine.tprog ts ts' -> s: StackMachine.vstack ts -> Prims.Tot (StackMachine.vstack ts')
Prims.Tot
[ "total", "" ]
[]
[ "StackMachine.tstack", "StackMachine.tprog", "StackMachine.vstack", "StackMachine.tinstr", "StackMachine.tprogDenote", "StackMachine.tinstrDenote" ]
[ "recursion" ]
false
false
false
false
false
let rec tprogDenote #ts #ts' (p: tprog ts ts') (s: vstack ts) : Tot (vstack ts') (decreases p) =
match p with | TNil -> s | TCons i p' -> tprogDenote p' (tinstrDenote i s)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.reset_512
val reset_512 : Hacl.Streaming.Functor.reset_st Hacl.Streaming.SHA2.hacl_sha2_512 (FStar.Ghost.hide (FStar.Ghost.reveal (FStar.Ghost.hide ()))) (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 82, "end_line": 170, "start_col": 0, "start_line": 170 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.reset_st Hacl.Streaming.SHA2.hacl_sha2_512 (FStar.Ghost.hide (FStar.Ghost.reveal (FStar.Ghost.hide ()))) (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.reset", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "FStar.Ghost.hide", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let reset_512 =
F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.update_512
val update_512:F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
val update_512:F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 154, "end_line": 182, "start_col": 0, "start_line": 182 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384.";
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_512 () (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.state", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased", "LowStar.Buffer.buffer", "Hacl.Streaming.Functor.uint8", "FStar.UInt32.t", "Hacl.Streaming.SHA2.update_384_512", "Hacl.Streaming.Types.error_code" ]
[]
false
false
false
false
false
let update_512:F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) =
fun state input input_len -> update_384_512 state input input_len
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.update_384
val update_384:F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
val update_384:F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
let update_384: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 154, "end_line": 220, "start_col": 0, "start_line": 220 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_512`. This function is identical to the free function for SHA2_384."; ] let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 64 bytes."] val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 let hash_512 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-384 // -------- inline_for_extraction noextract let alloca_384 = F.alloca hacl_sha2_384 () (state_384.s ()) (G.erased unit) let malloc_384 = F.malloc hacl_sha2_384 () (state_384.s ()) (G.erased unit)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_512 () (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.state", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased", "LowStar.Buffer.buffer", "Hacl.Streaming.Functor.uint8", "FStar.UInt32.t", "Hacl.Streaming.SHA2.update_384_512", "Hacl.Streaming.Types.error_code" ]
[]
false
false
false
false
false
let update_384:F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) =
fun state input input_len -> update_384_512 state input input_len
false
StackMachine.fst
StackMachine.tinstrDenote
val tinstrDenote (#ts #ts': tstack) (i: tinstr ts ts') (s: vstack ts) : Tot (vstack ts')
val tinstrDenote (#ts #ts': tstack) (i: tinstr ts ts') (s: vstack ts) : Tot (vstack ts')
let rec tinstrDenote (#ts:tstack) (#ts':tstack) (i : tinstr ts ts') (s:vstack ts) : Tot (vstack ts') = match i with | TiNConst _ n -> (n, s) | TiBConst _ b -> (b, s) | TiBinop #targ1 #targ2 #tres #tss b -> (* Take 1 *) (* let (arg1, (arg2, s')) = s in *) (* ((tbinopDenote b) arg1 arg2, s') *) (* Implicit pattern variables in (Prims.Mktuple2 arg1 (Prims.Mktuple2 arg2 s')) *) (* could not be resolved against expected type (StackMachine.vstack ts); *) (* Variables {?63598, ?63596, ?63406} were unresolved; please bind them explicitly *) (* Take 2 *) (* ((tbinopDenote b) (fst s) (fst (snd s)), (snd (snd s))) *) (* Subtyping check failed; expected type *) (* (Prims.tuple2 (?63342 ts ts' i s uu___ uu___ uu___ uu___ b) *) (* (?63343 ts ts' i s uu___ uu___ uu___ uu___ b)); *) (* got type (StackMachine.vstack ts) *) (* Take 3: fully annotated *) let s' : typeDenote targ1 * (typeDenote targ2 * vstack tss) = s in let (arg1, (arg2, s'')) = s' in (((tbinopDenote b) arg1 arg2, s'') <: (typeDenote tres * vstack tss))
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 77, "end_line": 174, "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. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2) let tstack = list typ type tinstr : tstack -> tstack -> Type0 = | TiNConst : s:tstack -> nat -> tinstr s (Nat :: s) | TiBConst : s:tstack -> bool -> tinstr s (Bool :: s) | TiBinop : #arg1:typ -> #arg2:typ -> #res:typ -> #s:tstack -> tbinop arg1 arg2 res -> tinstr (arg1 :: arg2 :: s) (res :: s) type tprog : tstack -> tstack -> Type0 = | TNil : #s:tstack -> tprog s s | TCons : #s1:tstack -> #s2:tstack -> #s3:tstack -> tinstr s1 s2 -> tprog s2 s3 -> tprog s1 s3 let rec vstack (ts : tstack) : Type0 = match ts with | [] -> unit | t :: ts' -> typeDenote t * vstack ts'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: StackMachine.tinstr ts ts' -> s: StackMachine.vstack ts -> StackMachine.vstack ts'
Prims.Tot
[ "total" ]
[]
[ "StackMachine.tstack", "StackMachine.tinstr", "StackMachine.vstack", "Prims.nat", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "StackMachine.typ", "StackMachine.tbinop", "StackMachine.typeDenote", "StackMachine.tbinopDenote", "FStar.Pervasives.Native.tuple2" ]
[ "recursion" ]
false
false
false
false
false
let rec tinstrDenote (#ts #ts': tstack) (i: tinstr ts ts') (s: vstack ts) : Tot (vstack ts') =
match i with | TiNConst _ n -> (n, s) | TiBConst _ b -> (b, s) | TiBinop #targ1 #targ2 #tres #tss b -> let s':typeDenote targ1 * (typeDenote targ2 * vstack tss) = s in let arg1, (arg2, s'') = s' in (((tbinopDenote b) arg1 arg2, s'') <: (typeDenote tres * vstack tss))
false
StackMachine.fst
StackMachine.typeDenote
val typeDenote (t: typ) : Type0
val typeDenote (t: typ) : Type0
let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 116, "start_col": 0, "start_line": 113 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: StackMachine.typ -> Type0
Prims.Tot
[ "total" ]
[]
[ "StackMachine.typ", "Prims.nat", "Prims.bool" ]
[]
false
false
false
true
true
let typeDenote (t: typ) : Type0 =
match t with | Nat -> nat | Bool -> bool
false
StackMachine.fst
StackMachine.instrDenote
val instrDenote (i: instr) (s: stack) : Tot (option stack)
val instrDenote (i: instr) (s: stack) : Tot (option stack)
let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 59, "start_col": 0, "start_line": 53 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: StackMachine.instr -> s: StackMachine.stack -> FStar.Pervasives.Native.option StackMachine.stack
Prims.Tot
[ "total" ]
[]
[ "StackMachine.instr", "StackMachine.stack", "Prims.nat", "FStar.Pervasives.Native.Some", "Prims.Cons", "StackMachine.binop", "Prims.list", "StackMachine.binopDenote", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
false
false
false
true
false
let instrDenote (i: instr) (s: stack) : Tot (option stack) =
match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None
false
StackMachine.fst
StackMachine.tcompile
val tcompile (#t: _) (e: texp t) (ts: tstack) : Tot (tprog ts (t :: ts)) (decreases e)
val tcompile (#t: _) (e: texp t) (ts: tstack) : Tot (tprog ts (t :: ts)) (decreases e)
let rec tcompile #t (e : texp t) (ts : tstack) : Tot (tprog ts (t :: ts)) (decreases e) = match e with | TNConst n -> TCons (TiNConst _ n) TNil | TBConst b -> TCons (TiBConst _ b) TNil | TBinop #t1 #t2 #t b e1 e2 -> tconcat (tcompile e2 _) (tconcat (tcompile e1 _) (TCons (TiBinop b) TNil))
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 194, "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. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2) let tstack = list typ type tinstr : tstack -> tstack -> Type0 = | TiNConst : s:tstack -> nat -> tinstr s (Nat :: s) | TiBConst : s:tstack -> bool -> tinstr s (Bool :: s) | TiBinop : #arg1:typ -> #arg2:typ -> #res:typ -> #s:tstack -> tbinop arg1 arg2 res -> tinstr (arg1 :: arg2 :: s) (res :: s) type tprog : tstack -> tstack -> Type0 = | TNil : #s:tstack -> tprog s s | TCons : #s1:tstack -> #s2:tstack -> #s3:tstack -> tinstr s1 s2 -> tprog s2 s3 -> tprog s1 s3 let rec vstack (ts : tstack) : Type0 = match ts with | [] -> unit | t :: ts' -> typeDenote t * vstack ts' let rec tinstrDenote (#ts:tstack) (#ts':tstack) (i : tinstr ts ts') (s:vstack ts) : Tot (vstack ts') = match i with | TiNConst _ n -> (n, s) | TiBConst _ b -> (b, s) | TiBinop #targ1 #targ2 #tres #tss b -> (* Take 1 *) (* let (arg1, (arg2, s')) = s in *) (* ((tbinopDenote b) arg1 arg2, s') *) (* Implicit pattern variables in (Prims.Mktuple2 arg1 (Prims.Mktuple2 arg2 s')) *) (* could not be resolved against expected type (StackMachine.vstack ts); *) (* Variables {?63598, ?63596, ?63406} were unresolved; please bind them explicitly *) (* Take 2 *) (* ((tbinopDenote b) (fst s) (fst (snd s)), (snd (snd s))) *) (* Subtyping check failed; expected type *) (* (Prims.tuple2 (?63342 ts ts' i s uu___ uu___ uu___ uu___ b) *) (* (?63343 ts ts' i s uu___ uu___ uu___ uu___ b)); *) (* got type (StackMachine.vstack ts) *) (* Take 3: fully annotated *) let s' : typeDenote targ1 * (typeDenote targ2 * vstack tss) = s in let (arg1, (arg2, s'')) = s' in (((tbinopDenote b) arg1 arg2, s'') <: (typeDenote tres * vstack tss)) let rec tprogDenote #ts #ts' (p : tprog ts ts') (s:vstack ts) : Tot (vstack ts') (decreases p) = match p with | TNil -> s | TCons i p' -> tprogDenote p' (tinstrDenote i s) let rec tconcat #ts #ts' #ts'' (p : tprog ts ts') (p' : tprog ts' ts'') : Tot (tprog ts ts'') (decreases p) = match p with | TNil -> p' | TCons i p1 -> TCons i (tconcat p1 p')
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
e: StackMachine.texp t -> ts: StackMachine.tstack -> Prims.Tot (StackMachine.tprog ts (t :: ts))
Prims.Tot
[ "total", "" ]
[]
[ "StackMachine.typ", "StackMachine.texp", "StackMachine.tstack", "Prims.nat", "StackMachine.TCons", "Prims.Cons", "StackMachine.Nat", "StackMachine.TiNConst", "StackMachine.TNil", "Prims.bool", "StackMachine.Bool", "StackMachine.TiBConst", "StackMachine.tbinop", "StackMachine.tconcat", "StackMachine.tcompile", "StackMachine.TiBinop", "StackMachine.tprog" ]
[ "recursion" ]
false
false
false
false
false
let rec tcompile #t (e: texp t) (ts: tstack) : Tot (tprog ts (t :: ts)) (decreases e) =
match e with | TNConst n -> TCons (TiNConst _ n) TNil | TBConst b -> TCons (TiBConst _ b) TNil | TBinop #t1 #t2 #t b e1 e2 -> tconcat (tcompile e2 _) (tconcat (tcompile e1 _) (TCons (TiBinop b) TNil))
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.free_512
val free_512 : Hacl.Streaming.Functor.free_st Hacl.Streaming.SHA2.hacl_sha2_512 (FStar.Ghost.reveal (FStar.Ghost.hide ())) (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 80, "end_line": 196, "start_col": 0, "start_line": 196 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_512`. This function is identical to the free function for SHA2_384.";
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.free_st Hacl.Streaming.SHA2.hacl_sha2_512 (FStar.Ghost.reveal (FStar.Ghost.hide ())) (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.free", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "FStar.Ghost.hide", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let free_512 =
F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.digest_224
val digest_224 : Hacl.Streaming.Functor.digest_st Hacl.Streaming.SHA2.hacl_sha2_224 () (Stateful?.s Hacl.Streaming.SHA2.state_224 ()) (FStar.Ghost.erased Prims.unit)
let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 138, "start_col": 0, "start_line": 138 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.digest_st Hacl.Streaming.SHA2.hacl_sha2_224 () (Stateful?.s Hacl.Streaming.SHA2.state_224 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.digest", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_224", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_224", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let digest_224 =
F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.update_224
val update_224:F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit)
val update_224:F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit)
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 154, "end_line": 132, "start_col": 0, "start_line": 132 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_256 () (Stateful?.s Hacl.Streaming.SHA2.state_256 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.state", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_256", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_256", "FStar.Ghost.erased", "LowStar.Buffer.buffer", "Hacl.Streaming.Functor.uint8", "FStar.UInt32.t", "Hacl.Streaming.SHA2.update_224_256", "Hacl.Streaming.Types.error_code" ]
[]
false
false
false
false
false
let update_224:F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) =
fun state input input_len -> update_224_256 state input input_len
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.digest_384
val digest_384 : Hacl.Streaming.Functor.digest_st Hacl.Streaming.SHA2.hacl_sha2_384 () (Stateful?.s Hacl.Streaming.SHA2.state_384 ()) (FStar.Ghost.erased Prims.unit)
let digest_384 = F.digest hacl_sha2_384 () (state_384.s ()) (G.erased unit)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 75, "end_line": 226, "start_col": 0, "start_line": 226 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_512`. This function is identical to the free function for SHA2_384."; ] let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 64 bytes."] val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 let hash_512 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-384 // -------- inline_for_extraction noextract let alloca_384 = F.alloca hacl_sha2_384 () (state_384.s ()) (G.erased unit) let malloc_384 = F.malloc hacl_sha2_384 () (state_384.s ()) (G.erased unit) let reset_384 = F.reset hacl_sha2_384 (G.hide ()) (state_384.s ()) (G.erased unit) let update_384: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 48 bytes. The state remains valid after a call to `digest_384`, meaning the user may feed more data into
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.digest_st Hacl.Streaming.SHA2.hacl_sha2_384 () (Stateful?.s Hacl.Streaming.SHA2.state_384 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.digest", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_384", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_384", "FStar.Ghost.erased" ]
[]
false
false
false
false
false
let digest_384 =
F.digest hacl_sha2_384 () (state_384.s ()) (G.erased unit)
false
StackMachine.fst
StackMachine.tconcat_correct
val tconcat_correct (#ts #ts' #ts'': _) (p: tprog ts ts') (p': tprog ts' ts'') (s: vstack ts) : Lemma (requires True) (ensures (tprogDenote (tconcat p p') s == tprogDenote p' (tprogDenote p s))) (decreases p) [SMTPat (tprogDenote (tconcat p p') s)]
val tconcat_correct (#ts #ts' #ts'': _) (p: tprog ts ts') (p': tprog ts' ts'') (s: vstack ts) : Lemma (requires True) (ensures (tprogDenote (tconcat p p') s == tprogDenote p' (tprogDenote p s))) (decreases p) [SMTPat (tprogDenote (tconcat p p') s)]
let rec tconcat_correct #ts #ts' #ts'' (p : tprog ts ts') (p' : tprog ts' ts'') (s : vstack ts) : Lemma (requires True) (ensures (tprogDenote (tconcat p p') s == tprogDenote p' (tprogDenote p s))) (decreases p) [SMTPat (tprogDenote (tconcat p p') s)] = match p with | TNil -> () | TCons t pp -> tconcat_correct pp p' (tinstrDenote t s)
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 205, "start_col": 0, "start_line": 198 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2) let tstack = list typ type tinstr : tstack -> tstack -> Type0 = | TiNConst : s:tstack -> nat -> tinstr s (Nat :: s) | TiBConst : s:tstack -> bool -> tinstr s (Bool :: s) | TiBinop : #arg1:typ -> #arg2:typ -> #res:typ -> #s:tstack -> tbinop arg1 arg2 res -> tinstr (arg1 :: arg2 :: s) (res :: s) type tprog : tstack -> tstack -> Type0 = | TNil : #s:tstack -> tprog s s | TCons : #s1:tstack -> #s2:tstack -> #s3:tstack -> tinstr s1 s2 -> tprog s2 s3 -> tprog s1 s3 let rec vstack (ts : tstack) : Type0 = match ts with | [] -> unit | t :: ts' -> typeDenote t * vstack ts' let rec tinstrDenote (#ts:tstack) (#ts':tstack) (i : tinstr ts ts') (s:vstack ts) : Tot (vstack ts') = match i with | TiNConst _ n -> (n, s) | TiBConst _ b -> (b, s) | TiBinop #targ1 #targ2 #tres #tss b -> (* Take 1 *) (* let (arg1, (arg2, s')) = s in *) (* ((tbinopDenote b) arg1 arg2, s') *) (* Implicit pattern variables in (Prims.Mktuple2 arg1 (Prims.Mktuple2 arg2 s')) *) (* could not be resolved against expected type (StackMachine.vstack ts); *) (* Variables {?63598, ?63596, ?63406} were unresolved; please bind them explicitly *) (* Take 2 *) (* ((tbinopDenote b) (fst s) (fst (snd s)), (snd (snd s))) *) (* Subtyping check failed; expected type *) (* (Prims.tuple2 (?63342 ts ts' i s uu___ uu___ uu___ uu___ b) *) (* (?63343 ts ts' i s uu___ uu___ uu___ uu___ b)); *) (* got type (StackMachine.vstack ts) *) (* Take 3: fully annotated *) let s' : typeDenote targ1 * (typeDenote targ2 * vstack tss) = s in let (arg1, (arg2, s'')) = s' in (((tbinopDenote b) arg1 arg2, s'') <: (typeDenote tres * vstack tss)) let rec tprogDenote #ts #ts' (p : tprog ts ts') (s:vstack ts) : Tot (vstack ts') (decreases p) = match p with | TNil -> s | TCons i p' -> tprogDenote p' (tinstrDenote i s) let rec tconcat #ts #ts' #ts'' (p : tprog ts ts') (p' : tprog ts' ts'') : Tot (tprog ts ts'') (decreases p) = match p with | TNil -> p' | TCons i p1 -> TCons i (tconcat p1 p') let rec tcompile #t (e : texp t) (ts : tstack) : Tot (tprog ts (t :: ts)) (decreases e) = match e with | TNConst n -> TCons (TiNConst _ n) TNil | TBConst b -> TCons (TiBConst _ b) TNil | TBinop #t1 #t2 #t b e1 e2 -> tconcat (tcompile e2 _) (tconcat (tcompile e1 _) (TCons (TiBinop b) TNil)) #reset-options "--z3rlimit 10"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: StackMachine.tprog ts ts' -> p': StackMachine.tprog ts' ts'' -> s: StackMachine.vstack ts -> FStar.Pervasives.Lemma (ensures StackMachine.tprogDenote (StackMachine.tconcat p p') s == StackMachine.tprogDenote p' (StackMachine.tprogDenote p s)) (decreases p) [SMTPat (StackMachine.tprogDenote (StackMachine.tconcat p p') s)]
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "StackMachine.tstack", "StackMachine.tprog", "StackMachine.vstack", "StackMachine.tinstr", "StackMachine.tconcat_correct", "StackMachine.tinstrDenote", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "StackMachine.tprogDenote", "StackMachine.tconcat", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[ "recursion" ]
false
false
true
false
false
let rec tconcat_correct #ts #ts' #ts'' (p: tprog ts ts') (p': tprog ts' ts'') (s: vstack ts) : Lemma (requires True) (ensures (tprogDenote (tconcat p p') s == tprogDenote p' (tprogDenote p s))) (decreases p) [SMTPat (tprogDenote (tconcat p p') s)] =
match p with | TNil -> () | TCons t pp -> tconcat_correct pp p' (tinstrDenote t s)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.free_384
val free_384:F.free_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
val free_384:F.free_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit)
let free_384: F.free_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state -> free_512 state
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 112, "end_line": 228, "start_col": 0, "start_line": 228 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_512`. This function is identical to the free function for SHA2_384."; ] let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 64 bytes."] val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 let hash_512 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-384 // -------- inline_for_extraction noextract let alloca_384 = F.alloca hacl_sha2_384 () (state_384.s ()) (G.erased unit) let malloc_384 = F.malloc hacl_sha2_384 () (state_384.s ()) (G.erased unit) let reset_384 = F.reset hacl_sha2_384 (G.hide ()) (state_384.s ()) (G.erased unit) let update_384: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 48 bytes. The state remains valid after a call to `digest_384`, meaning the user may feed more data into the hash via `update_384`."] let digest_384 = F.digest hacl_sha2_384 () (state_384.s ()) (G.erased unit)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Streaming.Functor.free_st Hacl.Streaming.SHA2.hacl_sha2_512 () (Stateful?.s Hacl.Streaming.SHA2.state_512 ()) (FStar.Ghost.erased Prims.unit)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Streaming.Functor.state", "Prims.unit", "Hacl.Streaming.SHA2.hacl_sha2_512", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "Hacl.Streaming.SHA2.state_512", "FStar.Ghost.erased", "Hacl.Streaming.SHA2.free_512" ]
[]
false
false
false
false
false
let free_384:F.free_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) =
fun state -> free_512 state
false
StackMachine.fst
StackMachine.tconcat
val tconcat (#ts #ts' #ts'': _) (p: tprog ts ts') (p': tprog ts' ts'') : Tot (tprog ts ts'') (decreases p)
val tconcat (#ts #ts' #ts'': _) (p: tprog ts ts') (p': tprog ts' ts'') : Tot (tprog ts ts'') (decreases p)
let rec tconcat #ts #ts' #ts'' (p : tprog ts ts') (p' : tprog ts' ts'') : Tot (tprog ts ts'') (decreases p) = match p with | TNil -> p' | TCons i p1 -> TCons i (tconcat p1 p')
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 186, "start_col": 0, "start_line": 182 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2) let tstack = list typ type tinstr : tstack -> tstack -> Type0 = | TiNConst : s:tstack -> nat -> tinstr s (Nat :: s) | TiBConst : s:tstack -> bool -> tinstr s (Bool :: s) | TiBinop : #arg1:typ -> #arg2:typ -> #res:typ -> #s:tstack -> tbinop arg1 arg2 res -> tinstr (arg1 :: arg2 :: s) (res :: s) type tprog : tstack -> tstack -> Type0 = | TNil : #s:tstack -> tprog s s | TCons : #s1:tstack -> #s2:tstack -> #s3:tstack -> tinstr s1 s2 -> tprog s2 s3 -> tprog s1 s3 let rec vstack (ts : tstack) : Type0 = match ts with | [] -> unit | t :: ts' -> typeDenote t * vstack ts' let rec tinstrDenote (#ts:tstack) (#ts':tstack) (i : tinstr ts ts') (s:vstack ts) : Tot (vstack ts') = match i with | TiNConst _ n -> (n, s) | TiBConst _ b -> (b, s) | TiBinop #targ1 #targ2 #tres #tss b -> (* Take 1 *) (* let (arg1, (arg2, s')) = s in *) (* ((tbinopDenote b) arg1 arg2, s') *) (* Implicit pattern variables in (Prims.Mktuple2 arg1 (Prims.Mktuple2 arg2 s')) *) (* could not be resolved against expected type (StackMachine.vstack ts); *) (* Variables {?63598, ?63596, ?63406} were unresolved; please bind them explicitly *) (* Take 2 *) (* ((tbinopDenote b) (fst s) (fst (snd s)), (snd (snd s))) *) (* Subtyping check failed; expected type *) (* (Prims.tuple2 (?63342 ts ts' i s uu___ uu___ uu___ uu___ b) *) (* (?63343 ts ts' i s uu___ uu___ uu___ uu___ b)); *) (* got type (StackMachine.vstack ts) *) (* Take 3: fully annotated *) let s' : typeDenote targ1 * (typeDenote targ2 * vstack tss) = s in let (arg1, (arg2, s'')) = s' in (((tbinopDenote b) arg1 arg2, s'') <: (typeDenote tres * vstack tss)) let rec tprogDenote #ts #ts' (p : tprog ts ts') (s:vstack ts) : Tot (vstack ts') (decreases p) = match p with | TNil -> s | TCons i p' -> tprogDenote p' (tinstrDenote i s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: StackMachine.tprog ts ts' -> p': StackMachine.tprog ts' ts'' -> Prims.Tot (StackMachine.tprog ts ts'')
Prims.Tot
[ "total", "" ]
[]
[ "StackMachine.tstack", "StackMachine.tprog", "StackMachine.tinstr", "StackMachine.TCons", "StackMachine.tconcat" ]
[ "recursion" ]
false
false
false
false
false
let rec tconcat #ts #ts' #ts'' (p: tprog ts ts') (p': tprog ts' ts'') : Tot (tprog ts ts'') (decreases p) =
match p with | TNil -> p' | TCons i p1 -> TCons i (tconcat p1 p')
false
StackMachine.fst
StackMachine.tcompile_correct'
val tcompile_correct' (#t: _) (e: texp t) (ts: _) (s: vstack ts) : Lemma (requires True) (ensures (tprogDenote (tcompile e ts) s == (texpDenote e, s))) (decreases e)
val tcompile_correct' (#t: _) (e: texp t) (ts: _) (s: vstack ts) : Lemma (requires True) (ensures (tprogDenote (tcompile e ts) s == (texpDenote e, s))) (decreases e)
let rec tcompile_correct' #t (e : texp t) ts (s : vstack ts) : Lemma (requires True) (ensures (tprogDenote (tcompile e ts) s == (texpDenote e, s))) (decreases e) = match e with | TNConst _ -> () | TBConst _ -> () | TBinop #t1 #t2 b e1 e2 -> tcompile_correct' e1 (t2 :: ts) (texpDenote e2, s); tcompile_correct' e2 ts s; let p1 = tcompile e1 (t1::ts) in let p = TCons (TiBinop b) TNil in tconcat_correct p1 p (texpDenote e2, s)
{ "file_name": "examples/metatheory/StackMachine.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 220, "start_col": 0, "start_line": 208 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module StackMachine (* A port of http://adam.chlipala.net/cpdt/html/Cpdt.StackMachine.html *) open FStar.List.Tot (* Compiling arithmetic expressions to stack machine *) type binop : Type0 = | Plus | Times type exp : Type0 = | Const : nat -> exp | Binop : binop -> exp -> exp -> exp let add_nat (n1:nat) (n2:nat) : Tot nat = n1 + n2 let mul_nat (n1:nat) (n2:nat) : Tot nat = n1 `op_Multiply` n2 let eq_nat (n1:nat) (n2:nat) : Tot bool = n1 = n2 let eq_bool (b1:bool) (b2:bool) : Tot bool = b1 = b2 let lt_nat (n1:nat) (n2:nat) : Tot bool = n1 < n2 let binopDenote (b : binop) : nat -> nat -> Tot nat = match b with | Plus -> add_nat | Times -> mul_nat let rec expDenote (e : exp) : Tot nat = match e with | Const n -> n | Binop b e1 e2 -> (binopDenote b) (expDenote e1) (expDenote e2) type instr : Type0 = | IConst : nat -> instr | IBinop : binop -> instr let prog = list instr let stack = list nat let instrDenote (i : instr) (s : stack) : Tot (option stack) = match i with | IConst n -> Some (n :: s) | IBinop b -> match s with | arg1 :: arg2 :: s' -> Some ((binopDenote b) arg1 arg2 :: s') | _ -> None let rec progDenote (p : prog) (s : stack) : Tot (option stack) = match p with | [] -> Some s | i :: p' -> match instrDenote i s with | None -> None | Some s' -> progDenote p' s' let rec compile (e : exp) : Tot prog = match e with | Const n -> [IConst n] | Binop b e1 e2 -> compile e2 @ compile e1 @ [IBinop b] let rec app_assoc_reverse (#a:Type) (l : list a) (m : list a) (n : list a) : Lemma (requires True) (ensures ((l @ m) @ n == l @ m @ n)) [SMTPat ((l @ m) @ n)] = match l with | [] -> () | _::l' -> app_assoc_reverse l' m n let rec compile_correct' e p s : Lemma (progDenote (compile e @ p) s = progDenote p (expDenote e :: s)) = match e with | Const _ -> () | Binop b e1 e2 -> compile_correct' e1 ([IBinop b] @ p) (expDenote e2 ::s); compile_correct' e2 (compile e1 @ [IBinop b] @ p) s (* Finding the right arguments to pass to the recursive calls without an interactive mode seems tricky; I just copied them from Adam *) let rec app_nil_end (#a : Type) (l : list a) : Lemma (requires True) (ensures (l == l @ [])) (decreases l) [SMTPat (l @ [])] = match l with | [] -> () | _::l' -> app_nil_end l' let compile_correct e : Lemma (progDenote (compile e) [] = Some [expDenote e]) = compile_correct' e [] [] (* Typed Expressions *) type typ : Type0 = | Nat | Bool type tbinop : typ -> typ -> typ -> Type0 = | TPlus : tbinop Nat Nat Nat | TTimes : tbinop Nat Nat Nat | TEq : t:typ -> tbinop t t Bool | TLt : tbinop Nat Nat Bool type texp : typ -> Type0 = | TNConst : nat -> texp Nat | TBConst : bool -> texp Bool | TBinop : #t1:typ -> #t2:typ -> #t:typ-> tbinop t1 t2 t -> texp t1 -> texp t2 -> texp t let typeDenote (t : typ) : Type0 = match t with | Nat -> nat | Bool -> bool let tbinopDenote #arg1 #arg2 #res (b : tbinop arg1 arg2 res) : typeDenote arg1 -> typeDenote arg2 -> Tot (typeDenote res) = match b with | TPlus -> add_nat | TTimes -> mul_nat | TEq Nat -> eq_nat | TEq Bool -> eq_bool | TLt -> lt_nat let rec texpDenote #t (e : texp t) : Tot (typeDenote t) (decreases e) = match e with | TNConst n -> n | TBConst b -> b | TBinop b e1 e2 -> (tbinopDenote b) (texpDenote e1) (texpDenote e2) let tstack = list typ type tinstr : tstack -> tstack -> Type0 = | TiNConst : s:tstack -> nat -> tinstr s (Nat :: s) | TiBConst : s:tstack -> bool -> tinstr s (Bool :: s) | TiBinop : #arg1:typ -> #arg2:typ -> #res:typ -> #s:tstack -> tbinop arg1 arg2 res -> tinstr (arg1 :: arg2 :: s) (res :: s) type tprog : tstack -> tstack -> Type0 = | TNil : #s:tstack -> tprog s s | TCons : #s1:tstack -> #s2:tstack -> #s3:tstack -> tinstr s1 s2 -> tprog s2 s3 -> tprog s1 s3 let rec vstack (ts : tstack) : Type0 = match ts with | [] -> unit | t :: ts' -> typeDenote t * vstack ts' let rec tinstrDenote (#ts:tstack) (#ts':tstack) (i : tinstr ts ts') (s:vstack ts) : Tot (vstack ts') = match i with | TiNConst _ n -> (n, s) | TiBConst _ b -> (b, s) | TiBinop #targ1 #targ2 #tres #tss b -> (* Take 1 *) (* let (arg1, (arg2, s')) = s in *) (* ((tbinopDenote b) arg1 arg2, s') *) (* Implicit pattern variables in (Prims.Mktuple2 arg1 (Prims.Mktuple2 arg2 s')) *) (* could not be resolved against expected type (StackMachine.vstack ts); *) (* Variables {?63598, ?63596, ?63406} were unresolved; please bind them explicitly *) (* Take 2 *) (* ((tbinopDenote b) (fst s) (fst (snd s)), (snd (snd s))) *) (* Subtyping check failed; expected type *) (* (Prims.tuple2 (?63342 ts ts' i s uu___ uu___ uu___ uu___ b) *) (* (?63343 ts ts' i s uu___ uu___ uu___ uu___ b)); *) (* got type (StackMachine.vstack ts) *) (* Take 3: fully annotated *) let s' : typeDenote targ1 * (typeDenote targ2 * vstack tss) = s in let (arg1, (arg2, s'')) = s' in (((tbinopDenote b) arg1 arg2, s'') <: (typeDenote tres * vstack tss)) let rec tprogDenote #ts #ts' (p : tprog ts ts') (s:vstack ts) : Tot (vstack ts') (decreases p) = match p with | TNil -> s | TCons i p' -> tprogDenote p' (tinstrDenote i s) let rec tconcat #ts #ts' #ts'' (p : tprog ts ts') (p' : tprog ts' ts'') : Tot (tprog ts ts'') (decreases p) = match p with | TNil -> p' | TCons i p1 -> TCons i (tconcat p1 p') let rec tcompile #t (e : texp t) (ts : tstack) : Tot (tprog ts (t :: ts)) (decreases e) = match e with | TNConst n -> TCons (TiNConst _ n) TNil | TBConst b -> TCons (TiBConst _ b) TNil | TBinop #t1 #t2 #t b e1 e2 -> tconcat (tcompile e2 _) (tconcat (tcompile e1 _) (TCons (TiBinop b) TNil)) #reset-options "--z3rlimit 10" let rec tconcat_correct #ts #ts' #ts'' (p : tprog ts ts') (p' : tprog ts' ts'') (s : vstack ts) : Lemma (requires True) (ensures (tprogDenote (tconcat p p') s == tprogDenote p' (tprogDenote p s))) (decreases p) [SMTPat (tprogDenote (tconcat p p') s)] = match p with | TNil -> () | TCons t pp -> tconcat_correct pp p' (tinstrDenote t s) (* again just taking Adam's instantiations *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "StackMachine.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: StackMachine.texp t -> ts: StackMachine.tstack -> s: StackMachine.vstack ts -> FStar.Pervasives.Lemma (ensures StackMachine.tprogDenote (StackMachine.tcompile e ts) s == (StackMachine.texpDenote e, s)) (decreases e)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "StackMachine.typ", "StackMachine.texp", "StackMachine.tstack", "StackMachine.vstack", "Prims.nat", "Prims.bool", "StackMachine.tbinop", "StackMachine.tconcat_correct", "Prims.Cons", "FStar.Pervasives.Native.Mktuple2", "StackMachine.typeDenote", "StackMachine.texpDenote", "StackMachine.tprog", "StackMachine.TCons", "StackMachine.TiBinop", "StackMachine.TNil", "StackMachine.tcompile", "Prims.unit", "StackMachine.tcompile_correct'", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "StackMachine.tprogDenote", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec tcompile_correct' #t (e: texp t) ts (s: vstack ts) : Lemma (requires True) (ensures (tprogDenote (tcompile e ts) s == (texpDenote e, s))) (decreases e) =
match e with | TNConst _ -> () | TBConst _ -> () | TBinop #t1 #t2 b e1 e2 -> tcompile_correct' e1 (t2 :: ts) (texpDenote e2, s); tcompile_correct' e2 ts s; let p1 = tcompile e1 (t1 :: ts) in let p = TCons (TiBinop b) TNil in tconcat_correct p1 p (texpDenote e2, s)
false
FStar.NMST.fst
FStar.NMST.bind
val bind (a b: Type) (state: Type u#2) (rel: P.preorder state) (req_f: M.pre_t state) (ens_f: M.post_t state a) (req_g: (a -> M.pre_t state)) (ens_g: (a -> M.post_t state b)) (f: repr a state rel req_f ens_f) (g: (x: a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
val bind (a b: Type) (state: Type u#2) (rel: P.preorder state) (req_f: M.pre_t state) (ens_f: M.post_t state a) (req_g: (a -> M.pre_t state)) (ens_g: (a -> M.post_t state b)) (f: repr a state rel req_f ens_f) (g: (x: a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1)
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 63, "start_col": 0, "start_line": 46 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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 -> state: Type -> rel: FStar.Preorder.preorder state -> req_f: FStar.MST.pre_t state -> ens_f: FStar.MST.post_t state a -> req_g: (_: a -> FStar.MST.pre_t state) -> ens_g: (_: a -> FStar.MST.post_t state b) -> f: FStar.NMST.repr a state rel req_f ens_f -> g: (x: a -> FStar.NMST.repr b state rel (req_g x) (ens_g x)) -> FStar.NMST.repr b state rel (fun s0 -> req_f s0 /\ (forall (x: a) (s1: state). ens_f s0 x s1 ==> req_g x s1)) (fun s0 r s2 -> req_f s0 /\ (exists (x: a) (s1: state). ens_f s0 x s1 /\ req_g x s1 /\ ens_g x s1 r s2))
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "FStar.MST.pre_t", "FStar.MST.post_t", "FStar.NMST.repr", "FStar.Pervasives.Native.tuple2", "FStar.NMST.tape", "Prims.nat", "FStar.Pervasives.Native.Mktuple2", "Prims.l_and", "Prims.l_Forall", "Prims.l_imp", "Prims.l_Exists" ]
[]
false
false
false
false
false
let bind (a b: Type) (state: Type u#2) (rel: P.preorder state) (req_f: M.pre_t state) (ens_f: M.post_t state a) (req_g: (a -> M.pre_t state)) (ens_g: (a -> M.post_t state b)) (f: repr a state rel req_f ens_f) (g: (x: a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) =
fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1)
false
FStar.NMST.fst
FStar.NMST.lift_nmst_total_nmst
val lift_nmst_total_nmst (a: Type) (state: Type u#2) (rel: P.preorder state) (req: M.pre_t state) (ens: M.post_t state a) (f: NMSTTotal.repr a state rel req ens) : repr a state rel req ens
val lift_nmst_total_nmst (a: Type) (state: Type u#2) (rel: P.preorder state) (req: M.pre_t state) (ens: M.post_t state a) (f: NMSTTotal.repr a state rel req ens) : repr a state rel req ens
let lift_nmst_total_nmst (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) (f:NMSTTotal.repr a state rel req ens) : repr a state rel req ens = fun (t, n) -> f (t, n)
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 222, "start_col": 0, "start_line": 218 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1) let subcomp (a:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:M.pre_t state) (ens_g:M.post_t state a) (f:repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) = f let if_then_else (a:Type) (state:Type u#2) (rel:P.preorder state) (req_then:M.pre_t state) (ens_then:M.post_t state a) (req_else:M.pre_t state) (ens_else:M.post_t state a) (f:repr a state rel req_then ens_then) (g:repr a state rel req_else ens_else) (p:bool) : Type = repr a state rel (fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0)) (fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1)) [@@ primitive_extraction] reflectable effect { NMSTATE (a:Type) ([@@@ effect_param] state:Type u#2) ([@@@ effect_param] rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) with { repr; return; bind; subcomp; if_then_else } } [@@ noextract_to "krml"] let get (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMSTATE?.reflect (fun (_, n) -> MST.get (), n) [@@ noextract_to "krml"] let put (#state:Type u#2) (#rel:P.preorder state) (s:state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) = NMSTATE?.reflect (fun (_, n) -> MST.put s, n) [@@ noextract_to "krml"] let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) : NMSTATE (W.witnessed state rel p) state rel (fun s0 -> p s0 /\ W.stable state rel p) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n) [@@ noextract_to "krml"] let recall (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) (w:W.witnessed state rel p) : NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) = NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n) [@@ noextract_to "krml"] let sample (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (t, n) -> t n, n+1) let lift_pure_nmst (a:Type) (wp:pure_wp a) (state:Type u#2) (rel:P.preorder state) (f:eqtype_as_type unit -> PURE a wp) : repr a state rel (fun s0 -> wp (fun _ -> True)) (fun s0 x s1 -> wp (fun _ -> True) /\ (~ (wp (fun r -> r =!= x \/ s0 =!= s1)))) = fun (_, n) -> elim_pure_wp_monotonicity wp; let x = f () in x, n sub_effect PURE ~> NMSTATE = lift_pure_nmst (* * A polymonadic bind between DIV and NMSTATE * * This is ultimately used when defining par and frame in Steel.Effect.fst * par and frame try to compose reified Steel with Steel, since Steel is non total, its reification * incurs a Div effect, and so, we need a way to compose Div and Steel * * To do so, we have to go all the way down and have a story for MST and NMST too * * This polymonadic bind gives us bare minimum to realize that * It is quite imprecise, in that it doesn't say anything about the post of the Div computation * That's because, the as_ensures combinator is not encoded for Div effect in the SMT, * the way it is done for PURE and GHOST * * However, since the reification use case gives us Dv anyway, this is fine for now *) let bind_div_nmst (a:Type) (b:Type) (wp:pure_wp a) (state:Type u#2) (rel:P.preorder state) (req:a -> M.pre_t state) (ens:a -> M.post_t state b) (f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b state rel (req x) (ens x))) : repr b state rel (fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0)) (fun s0 y s1 -> exists x. (ens x) s0 y s1) = elim_pure_wp_monotonicity wp; fun s0 -> let x = f () in (g x) s0 polymonadic_bind (DIV, NMSTATE) |> NMSTATE = bind_div_nmst let nmst_assume (#state:Type u#2) (#rel:P.preorder state) (p:Type) : NMSTATE unit state rel (fun _ -> True) (fun m0 _ m1 -> p /\ m0 == m1) = assume p let nmst_admit (#state:Type u#2) (#rel:P.preorder state) (#a:Type) () : NMSTATE a state rel (fun _ -> True) (fun _ _ _ -> False) = admit () let nmst_assert (#state:Type u#2) (#rel:P.preorder state) (p:Type) : NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) = assert p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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 -> state: Type -> rel: FStar.Preorder.preorder state -> req: FStar.MST.pre_t state -> ens: FStar.MST.post_t state a -> f: FStar.NMSTTotal.repr a state rel req ens -> FStar.NMST.repr a state rel req ens
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "FStar.MST.pre_t", "FStar.MST.post_t", "FStar.NMSTTotal.repr", "FStar.Pervasives.Native.tuple2", "FStar.NMST.tape", "Prims.nat", "FStar.Pervasives.Native.Mktuple2", "FStar.NMSTTotal.tape", "FStar.NMST.repr" ]
[]
false
false
false
false
false
let lift_nmst_total_nmst (a: Type) (state: Type u#2) (rel: P.preorder state) (req: M.pre_t state) (ens: M.post_t state a) (f: NMSTTotal.repr a state rel req ens) : repr a state rel req ens =
fun (t, n) -> f (t, n)
false
FStar.NMST.fst
FStar.NMST.put
val put (#state: Type u#2) (#rel: P.preorder state) (s: state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s)
val put (#state: Type u#2) (#rel: P.preorder state) (s: state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s)
let put (#state:Type u#2) (#rel:P.preorder state) (s:state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) = NMSTATE?.reflect (fun (_, n) -> MST.put s, n)
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 124, "start_col": 0, "start_line": 119 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1) let subcomp (a:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:M.pre_t state) (ens_g:M.post_t state a) (f:repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) = f let if_then_else (a:Type) (state:Type u#2) (rel:P.preorder state) (req_then:M.pre_t state) (ens_then:M.post_t state a) (req_else:M.pre_t state) (ens_else:M.post_t state a) (f:repr a state rel req_then ens_then) (g:repr a state rel req_else ens_else) (p:bool) : Type = repr a state rel (fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0)) (fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1)) [@@ primitive_extraction] reflectable effect { NMSTATE (a:Type) ([@@@ effect_param] state:Type u#2) ([@@@ effect_param] rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) with { repr; return; bind; subcomp; if_then_else } } [@@ noextract_to "krml"] let get (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: state -> FStar.NMST.NMSTATE Prims.unit
FStar.NMST.NMSTATE
[]
[]
[ "FStar.Preorder.preorder", "FStar.Pervasives.Native.tuple2", "FStar.NMST.tape", "Prims.nat", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "FStar.MST.put", "Prims.eq2" ]
[]
false
true
false
false
false
let put (#state: Type u#2) (#rel: P.preorder state) (s: state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) =
NMSTATE?.reflect (fun (_, n) -> MST.put s, n)
false
FStar.NMST.fst
FStar.NMST.subcomp
val subcomp (a: Type) (state: Type u#2) (rel: P.preorder state) (req_f: M.pre_t state) (ens_f: M.post_t state a) (req_g: M.pre_t state) (ens_g: M.post_t state a) (f: repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True)
val subcomp (a: Type) (state: Type u#2) (rel: P.preorder state) (req_f: M.pre_t state) (ens_f: M.post_t state a) (req_g: M.pre_t state) (ens_g: M.post_t state a) (f: repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True)
let subcomp (a:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:M.pre_t state) (ens_g:M.post_t state a) (f:repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) = f
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 80, "start_col": 0, "start_line": 65 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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 -> state: Type -> rel: FStar.Preorder.preorder state -> req_f: FStar.MST.pre_t state -> ens_f: FStar.MST.post_t state a -> req_g: FStar.MST.pre_t state -> ens_g: FStar.MST.post_t state a -> f: FStar.NMST.repr a state rel req_f ens_f -> Prims.Pure (FStar.NMST.repr a state rel req_g ens_g)
Prims.Pure
[]
[]
[ "FStar.Preorder.preorder", "FStar.MST.pre_t", "FStar.MST.post_t", "FStar.NMST.repr", "Prims.l_and", "Prims.l_Forall", "Prims.l_imp", "Prims.l_True" ]
[]
false
false
false
false
false
let subcomp (a: Type) (state: Type u#2) (rel: P.preorder state) (req_f: M.pre_t state) (ens_f: M.post_t state a) (req_g: M.pre_t state) (ens_g: M.post_t state a) (f: repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) =
f
false
FStar.NMST.fst
FStar.NMST.get
val get: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit -> NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1)
val get: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit -> NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1)
let get (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 116, "start_col": 0, "start_line": 111 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1) let subcomp (a:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:M.pre_t state) (ens_g:M.post_t state a) (f:repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) = f let if_then_else (a:Type) (state:Type u#2) (rel:P.preorder state) (req_then:M.pre_t state) (ens_then:M.post_t state a) (req_else:M.pre_t state) (ens_else:M.post_t state a) (f:repr a state rel req_then ens_then) (g:repr a state rel req_else ens_else) (p:bool) : Type = repr a state rel (fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0)) (fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1)) [@@ primitive_extraction] reflectable effect { NMSTATE (a:Type) ([@@@ effect_param] state:Type u#2) ([@@@ effect_param] rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) with { repr; return; bind; subcomp; if_then_else } }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.NMST.NMSTATE state
FStar.NMST.NMSTATE
[]
[]
[ "FStar.Preorder.preorder", "Prims.unit", "FStar.Pervasives.Native.tuple2", "FStar.NMST.tape", "Prims.nat", "FStar.Pervasives.Native.Mktuple2", "FStar.MST.get", "Prims.l_True", "Prims.l_and", "Prims.eq2" ]
[]
false
true
false
false
false
let get (#state: Type u#2) (#rel: P.preorder state) () : NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) =
NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
false
FStar.NMST.fst
FStar.NMST.sample
val sample: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit -> NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1)
val sample: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit -> NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1)
let sample (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (t, n) -> t n, n+1)
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 152, "start_col": 0, "start_line": 147 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1) let subcomp (a:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:M.pre_t state) (ens_g:M.post_t state a) (f:repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) = f let if_then_else (a:Type) (state:Type u#2) (rel:P.preorder state) (req_then:M.pre_t state) (ens_then:M.post_t state a) (req_else:M.pre_t state) (ens_else:M.post_t state a) (f:repr a state rel req_then ens_then) (g:repr a state rel req_else ens_else) (p:bool) : Type = repr a state rel (fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0)) (fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1)) [@@ primitive_extraction] reflectable effect { NMSTATE (a:Type) ([@@@ effect_param] state:Type u#2) ([@@@ effect_param] rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) with { repr; return; bind; subcomp; if_then_else } } [@@ noextract_to "krml"] let get (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMSTATE?.reflect (fun (_, n) -> MST.get (), n) [@@ noextract_to "krml"] let put (#state:Type u#2) (#rel:P.preorder state) (s:state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) = NMSTATE?.reflect (fun (_, n) -> MST.put s, n) [@@ noextract_to "krml"] let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) : NMSTATE (W.witnessed state rel p) state rel (fun s0 -> p s0 /\ W.stable state rel p) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n) [@@ noextract_to "krml"] let recall (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) (w:W.witnessed state rel p) : NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) = NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.NMST.NMSTATE Prims.bool
FStar.NMST.NMSTATE
[]
[]
[ "FStar.Preorder.preorder", "Prims.unit", "FStar.Pervasives.Native.tuple2", "FStar.NMST.tape", "Prims.nat", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "Prims.op_Addition", "Prims.l_True", "Prims.eq2" ]
[]
false
true
false
false
false
let sample (#state: Type u#2) (#rel: P.preorder state) () : NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) =
NMSTATE?.reflect (fun (t, n) -> t n, n + 1)
false
FStar.NMST.fst
FStar.NMST.return
val return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
val return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 44, "start_col": 0, "start_line": 41 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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 -> x: a -> state: Type -> rel: FStar.Preorder.preorder state -> FStar.NMST.repr a state rel (fun _ -> Prims.l_True) (fun s0 r s1 -> r == x /\ s0 == s1)
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "FStar.Pervasives.Native.tuple2", "FStar.NMST.tape", "Prims.nat", "FStar.Pervasives.Native.Mktuple2", "FStar.NMST.repr", "Prims.l_True", "Prims.l_and", "Prims.eq2" ]
[]
false
false
false
false
false
let return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) =
fun (_, n) -> x, n
false
FStar.NMST.fst
FStar.NMST.witness
val witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state) : NMSTATE (W.witnessed state rel p) state rel (fun s0 -> p s0 /\ W.stable state rel p) (fun s0 _ s1 -> s0 == s1)
val witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state) : NMSTATE (W.witnessed state rel p) state rel (fun s0 -> p s0 /\ W.stable state rel p) (fun s0 _ s1 -> s0 == s1)
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) : NMSTATE (W.witnessed state rel p) state rel (fun s0 -> p s0 /\ W.stable state rel p) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n)
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 133, "start_col": 0, "start_line": 128 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1) let subcomp (a:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:M.pre_t state) (ens_g:M.post_t state a) (f:repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) = f let if_then_else (a:Type) (state:Type u#2) (rel:P.preorder state) (req_then:M.pre_t state) (ens_then:M.post_t state a) (req_else:M.pre_t state) (ens_else:M.post_t state a) (f:repr a state rel req_then ens_then) (g:repr a state rel req_else ens_else) (p:bool) : Type = repr a state rel (fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0)) (fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1)) [@@ primitive_extraction] reflectable effect { NMSTATE (a:Type) ([@@@ effect_param] state:Type u#2) ([@@@ effect_param] rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) with { repr; return; bind; subcomp; if_then_else } } [@@ noextract_to "krml"] let get (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMSTATE?.reflect (fun (_, n) -> MST.get (), n) [@@ noextract_to "krml"] let put (#state:Type u#2) (#rel:P.preorder state) (s:state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) = NMSTATE?.reflect (fun (_, n) -> MST.put s, n)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
state: Type -> rel: FStar.Preorder.preorder state -> p: FStar.Witnessed.Core.s_predicate state -> FStar.NMST.NMSTATE (FStar.Witnessed.Core.witnessed state rel p)
FStar.NMST.NMSTATE
[]
[]
[ "FStar.Preorder.preorder", "FStar.Witnessed.Core.s_predicate", "FStar.Pervasives.Native.tuple2", "FStar.NMST.tape", "Prims.nat", "FStar.Pervasives.Native.Mktuple2", "FStar.Witnessed.Core.witnessed", "FStar.MST.witness", "Prims.l_and", "FStar.Witnessed.Core.stable", "Prims.eq2" ]
[]
false
true
false
false
false
let witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state) : NMSTATE (W.witnessed state rel p) state rel (fun s0 -> p s0 /\ W.stable state rel p) (fun s0 _ s1 -> s0 == s1) =
NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n)
false
FStar.NMST.fst
FStar.NMST.nmst_assert
val nmst_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type) : NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1)
val nmst_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type) : NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1)
let nmst_assert (#state:Type u#2) (#rel:P.preorder state) (p:Type) : NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) = assert p
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 216, "start_col": 0, "start_line": 213 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1) let subcomp (a:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:M.pre_t state) (ens_g:M.post_t state a) (f:repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) = f let if_then_else (a:Type) (state:Type u#2) (rel:P.preorder state) (req_then:M.pre_t state) (ens_then:M.post_t state a) (req_else:M.pre_t state) (ens_else:M.post_t state a) (f:repr a state rel req_then ens_then) (g:repr a state rel req_else ens_else) (p:bool) : Type = repr a state rel (fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0)) (fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1)) [@@ primitive_extraction] reflectable effect { NMSTATE (a:Type) ([@@@ effect_param] state:Type u#2) ([@@@ effect_param] rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) with { repr; return; bind; subcomp; if_then_else } } [@@ noextract_to "krml"] let get (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMSTATE?.reflect (fun (_, n) -> MST.get (), n) [@@ noextract_to "krml"] let put (#state:Type u#2) (#rel:P.preorder state) (s:state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) = NMSTATE?.reflect (fun (_, n) -> MST.put s, n) [@@ noextract_to "krml"] let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) : NMSTATE (W.witnessed state rel p) state rel (fun s0 -> p s0 /\ W.stable state rel p) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n) [@@ noextract_to "krml"] let recall (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) (w:W.witnessed state rel p) : NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) = NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n) [@@ noextract_to "krml"] let sample (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (t, n) -> t n, n+1) let lift_pure_nmst (a:Type) (wp:pure_wp a) (state:Type u#2) (rel:P.preorder state) (f:eqtype_as_type unit -> PURE a wp) : repr a state rel (fun s0 -> wp (fun _ -> True)) (fun s0 x s1 -> wp (fun _ -> True) /\ (~ (wp (fun r -> r =!= x \/ s0 =!= s1)))) = fun (_, n) -> elim_pure_wp_monotonicity wp; let x = f () in x, n sub_effect PURE ~> NMSTATE = lift_pure_nmst (* * A polymonadic bind between DIV and NMSTATE * * This is ultimately used when defining par and frame in Steel.Effect.fst * par and frame try to compose reified Steel with Steel, since Steel is non total, its reification * incurs a Div effect, and so, we need a way to compose Div and Steel * * To do so, we have to go all the way down and have a story for MST and NMST too * * This polymonadic bind gives us bare minimum to realize that * It is quite imprecise, in that it doesn't say anything about the post of the Div computation * That's because, the as_ensures combinator is not encoded for Div effect in the SMT, * the way it is done for PURE and GHOST * * However, since the reification use case gives us Dv anyway, this is fine for now *) let bind_div_nmst (a:Type) (b:Type) (wp:pure_wp a) (state:Type u#2) (rel:P.preorder state) (req:a -> M.pre_t state) (ens:a -> M.post_t state b) (f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b state rel (req x) (ens x))) : repr b state rel (fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0)) (fun s0 y s1 -> exists x. (ens x) s0 y s1) = elim_pure_wp_monotonicity wp; fun s0 -> let x = f () in (g x) s0 polymonadic_bind (DIV, NMSTATE) |> NMSTATE = bind_div_nmst let nmst_assume (#state:Type u#2) (#rel:P.preorder state) (p:Type) : NMSTATE unit state rel (fun _ -> True) (fun m0 _ m1 -> p /\ m0 == m1) = assume p let nmst_admit (#state:Type u#2) (#rel:P.preorder state) (#a:Type) () : NMSTATE a state rel (fun _ -> True) (fun _ _ _ -> False) = admit ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: Type0 -> FStar.NMST.NMSTATE Prims.unit
FStar.NMST.NMSTATE
[]
[]
[ "FStar.Preorder.preorder", "Prims._assert", "Prims.unit", "Prims.l_and", "Prims.eq2" ]
[]
false
true
false
false
false
let nmst_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type) : NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) =
assert p
false
FStar.NMST.fst
FStar.NMST.recall
val recall (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state) (w: W.witnessed state rel p) : NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1)
val recall (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state) (w: W.witnessed state rel p) : NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1)
let recall (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) (w:W.witnessed state rel p) : NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) = NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n)
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 60, "end_line": 144, "start_col": 0, "start_line": 136 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1) let subcomp (a:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:M.pre_t state) (ens_g:M.post_t state a) (f:repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) = f let if_then_else (a:Type) (state:Type u#2) (rel:P.preorder state) (req_then:M.pre_t state) (ens_then:M.post_t state a) (req_else:M.pre_t state) (ens_else:M.post_t state a) (f:repr a state rel req_then ens_then) (g:repr a state rel req_else ens_else) (p:bool) : Type = repr a state rel (fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0)) (fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1)) [@@ primitive_extraction] reflectable effect { NMSTATE (a:Type) ([@@@ effect_param] state:Type u#2) ([@@@ effect_param] rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) with { repr; return; bind; subcomp; if_then_else } } [@@ noextract_to "krml"] let get (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMSTATE?.reflect (fun (_, n) -> MST.get (), n) [@@ noextract_to "krml"] let put (#state:Type u#2) (#rel:P.preorder state) (s:state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) = NMSTATE?.reflect (fun (_, n) -> MST.put s, n) [@@ noextract_to "krml"] let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) : NMSTATE (W.witnessed state rel p) state rel (fun s0 -> p s0 /\ W.stable state rel p) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
state: Type -> rel: FStar.Preorder.preorder state -> p: FStar.Witnessed.Core.s_predicate state -> w: FStar.Witnessed.Core.witnessed state rel p -> FStar.NMST.NMSTATE Prims.unit
FStar.NMST.NMSTATE
[]
[]
[ "FStar.Preorder.preorder", "FStar.Witnessed.Core.s_predicate", "FStar.Witnessed.Core.witnessed", "FStar.Pervasives.Native.tuple2", "FStar.NMST.tape", "Prims.nat", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "FStar.MST.recall", "Prims.l_True", "Prims.l_and", "Prims.eq2" ]
[]
false
true
false
false
false
let recall (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state) (w: W.witnessed state rel p) : NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) =
NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n)
false
FStar.NMST.fst
FStar.NMST.bind_div_nmst
val bind_div_nmst (a b: Type) (wp: pure_wp a) (state: Type u#2) (rel: P.preorder state) (req: (a -> M.pre_t state)) (ens: (a -> M.post_t state b)) (f: (eqtype_as_type unit -> DIV a wp)) (g: (x: a -> repr b state rel (req x) (ens x))) : repr b state rel (fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0)) (fun s0 y s1 -> exists x. (ens x) s0 y s1)
val bind_div_nmst (a b: Type) (wp: pure_wp a) (state: Type u#2) (rel: P.preorder state) (req: (a -> M.pre_t state)) (ens: (a -> M.post_t state b)) (f: (eqtype_as_type unit -> DIV a wp)) (g: (x: a -> repr b state rel (req x) (ens x))) : repr b state rel (fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0)) (fun s0 y s1 -> exists x. (ens x) s0 y s1)
let bind_div_nmst (a:Type) (b:Type) (wp:pure_wp a) (state:Type u#2) (rel:P.preorder state) (req:a -> M.pre_t state) (ens:a -> M.post_t state b) (f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b state rel (req x) (ens x))) : repr b state rel (fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0)) (fun s0 y s1 -> exists x. (ens x) s0 y s1) = elim_pure_wp_monotonicity wp; fun s0 -> let x = f () in (g x) s0
{ "file_name": "ulib/experimental/FStar.NMST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 198, "start_col": 0, "start_line": 188 }
(* 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 FStar.NMST #set-options "--compat_pre_typed_indexed_effects" module W = FStar.Witnessed.Core module P = FStar.Preorder module M = FStar.MST open FStar.Monotonic.Pure type tape = nat -> bool type repr (a:Type) (state:Type u#2) (rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) = (tape & nat) -> M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1) let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state) : repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = fun (_, n) -> x, n let bind (a:Type) (b:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:a -> M.pre_t state) (ens_g:a -> M.post_t state b) (f:repr a state rel req_f ens_f) (g:(x:a -> repr b state rel (req_g x) (ens_g x))) : repr b state rel (fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1)) (fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = fun (t, n) -> let x, n1 = f (t, n) in (g x) (t, n1) let subcomp (a:Type) (state:Type u#2) (rel:P.preorder state) (req_f:M.pre_t state) (ens_f:M.post_t state a) (req_g:M.pre_t state) (ens_g:M.post_t state a) (f:repr a state rel req_f ens_f) : Pure (repr a state rel req_g ens_g) (requires (forall s. req_g s ==> req_f s) /\ (forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1)) (ensures fun _ -> True) = f let if_then_else (a:Type) (state:Type u#2) (rel:P.preorder state) (req_then:M.pre_t state) (ens_then:M.post_t state a) (req_else:M.pre_t state) (ens_else:M.post_t state a) (f:repr a state rel req_then ens_then) (g:repr a state rel req_else ens_else) (p:bool) : Type = repr a state rel (fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0)) (fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1)) [@@ primitive_extraction] reflectable effect { NMSTATE (a:Type) ([@@@ effect_param] state:Type u#2) ([@@@ effect_param] rel:P.preorder state) (req:M.pre_t state) (ens:M.post_t state a) with { repr; return; bind; subcomp; if_then_else } } [@@ noextract_to "krml"] let get (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = NMSTATE?.reflect (fun (_, n) -> MST.get (), n) [@@ noextract_to "krml"] let put (#state:Type u#2) (#rel:P.preorder state) (s:state) : NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) = NMSTATE?.reflect (fun (_, n) -> MST.put s, n) [@@ noextract_to "krml"] let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) : NMSTATE (W.witnessed state rel p) state rel (fun s0 -> p s0 /\ W.stable state rel p) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n) [@@ noextract_to "krml"] let recall (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state) (w:W.witnessed state rel p) : NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) = NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n) [@@ noextract_to "krml"] let sample (#state:Type u#2) (#rel:P.preorder state) () : NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) = NMSTATE?.reflect (fun (t, n) -> t n, n+1) let lift_pure_nmst (a:Type) (wp:pure_wp a) (state:Type u#2) (rel:P.preorder state) (f:eqtype_as_type unit -> PURE a wp) : repr a state rel (fun s0 -> wp (fun _ -> True)) (fun s0 x s1 -> wp (fun _ -> True) /\ (~ (wp (fun r -> r =!= x \/ s0 =!= s1)))) = fun (_, n) -> elim_pure_wp_monotonicity wp; let x = f () in x, n sub_effect PURE ~> NMSTATE = lift_pure_nmst (* * A polymonadic bind between DIV and NMSTATE * * This is ultimately used when defining par and frame in Steel.Effect.fst * par and frame try to compose reified Steel with Steel, since Steel is non total, its reification * incurs a Div effect, and so, we need a way to compose Div and Steel * * To do so, we have to go all the way down and have a story for MST and NMST too * * This polymonadic bind gives us bare minimum to realize that * It is quite imprecise, in that it doesn't say anything about the post of the Div computation * That's because, the as_ensures combinator is not encoded for Div effect in the SMT, * the way it is done for PURE and GHOST * * However, since the reification use case gives us Dv anyway, this is fine for now
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Witnessed.Core.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.MST.fst.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "FStar.NMST.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "FStar.MST", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Witnessed.Core", "short_module": "W" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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 -> wp: Prims.pure_wp a -> state: Type -> rel: FStar.Preorder.preorder state -> req: (_: a -> FStar.MST.pre_t state) -> ens: (_: a -> FStar.MST.post_t state b) -> f: (_: FStar.Pervasives.eqtype_as_type Prims.unit -> FStar.Pervasives.DIV a) -> g: (x: a -> FStar.NMST.repr b state rel (req x) (ens x)) -> FStar.NMST.repr b state rel (fun s0 -> wp (fun _ -> Prims.l_True) /\ (forall (x: a). req x s0)) (fun s0 y s1 -> exists (x: a). ens x s0 y s1)
Prims.Tot
[ "total" ]
[]
[ "Prims.pure_wp", "FStar.Preorder.preorder", "FStar.MST.pre_t", "FStar.MST.post_t", "FStar.Pervasives.eqtype_as_type", "Prims.unit", "FStar.NMST.repr", "FStar.Pervasives.Native.tuple2", "FStar.NMST.tape", "Prims.nat", "FStar.Monotonic.Pure.elim_pure_wp_monotonicity", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_Exists" ]
[]
false
false
false
false
false
let bind_div_nmst (a b: Type) (wp: pure_wp a) (state: Type u#2) (rel: P.preorder state) (req: (a -> M.pre_t state)) (ens: (a -> M.post_t state b)) (f: (eqtype_as_type unit -> DIV a wp)) (g: (x: a -> repr b state rel (req x) (ens x))) : repr b state rel (fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0)) (fun s0 y s1 -> exists x. (ens x) s0 y s1) =
elim_pure_wp_monotonicity wp; fun s0 -> let x = f () in (g x) s0
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.hash_256
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 122, "start_col": 0, "start_line": 112 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."]
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_256
Prims.Tot
[ "total" ]
[]
[ "Hacl.Hash.Definitions.hash_t", "Spec.Hash.Definitions.SHA2_256", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.nat", "FStar.Seq.Base.length", "Hacl.Hash.Definitions.hash_len", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.M32", "Lib.MultiBuffer.as_seq_multi", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.unit", "Hacl.Spec.SHA2.Equiv.hash_agile_lemma", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.SHA2.Generic.hash", "Hacl.SHA2.Scalar32.sha256_init", "Hacl.SHA2.Scalar32.sha256_update_nblocks", "Hacl.SHA2.Scalar32.sha256_update_last", "Hacl.SHA2.Scalar32.sha256_finish", "Lib.MultiBuffer.loc_multi1", "Lib.NTuple.ntuple", "Lib.Buffer.lbuffer_t", "Lib.NTuple.ntup1", "Lib.Buffer.lbuffer" ]
[]
false
false
false
true
false
let hash_256 output input input_len =
[@@ inline_let ]let output:lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get () in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get () in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 output)
false
Hacl.GenericField32.fst
Hacl.GenericField32.km
val km : len: Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs -> Hacl.Bignum.Montgomery.mont Hacl.GenericField32.t_limbs
let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 13, "start_col": 0, "start_line": 12 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs -> Hacl.Bignum.Montgomery.mont Hacl.GenericField32.t_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.Montgomery.mk_runtime_mont", "Hacl.Bignum.Montgomery.mont" ]
[]
false
false
false
true
false
let km (len: BN.meta_len t_limbs) =
BM.mk_runtime_mont len
false
Hacl.GenericField32.fst
Hacl.GenericField32.field_free
val field_free: MA.bn_field_free_st t_limbs
val field_free: MA.bn_field_free_st t_limbs
let field_free k = MA.bn_field_free k
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 20, "end_line": 22, "start_col": 0, "start_line": 21 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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.GenericField32.t_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.bn_field_free", "Prims.unit" ]
[]
false
false
false
true
false
let field_free k =
MA.bn_field_free k
false
Hacl.GenericField32.fst
Hacl.GenericField32.field_get_len
val field_get_len: MA.bn_field_get_len_st t_limbs
val field_get_len: MA.bn_field_get_len_st t_limbs
let field_get_len k = MA.bn_field_get_len k
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 25, "start_col": 0, "start_line": 24 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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_get_len_st Hacl.GenericField32.t_limbs
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.bn_field_get_len", "Hacl.Bignum.meta_len" ]
[]
false
false
false
true
false
let field_get_len k =
MA.bn_field_get_len k
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.hash_224
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 154, "start_col": 0, "start_line": 144 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."]
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_224
Prims.Tot
[ "total" ]
[]
[ "Hacl.Hash.Definitions.hash_t", "Spec.Hash.Definitions.SHA2_224", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.nat", "FStar.Seq.Base.length", "Hacl.Hash.Definitions.hash_len", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.M32", "Lib.MultiBuffer.as_seq_multi", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.unit", "Hacl.Spec.SHA2.Equiv.hash_agile_lemma", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.SHA2.Generic.hash", "Hacl.SHA2.Scalar32.sha224_init", "Hacl.SHA2.Scalar32.sha224_update_nblocks", "Hacl.SHA2.Scalar32.sha224_update_last", "Hacl.SHA2.Scalar32.sha224_finish", "Lib.MultiBuffer.loc_multi1", "Lib.NTuple.ntuple", "Lib.Buffer.lbuffer_t", "Lib.NTuple.ntup1", "Lib.Buffer.lbuffer" ]
[]
false
false
false
true
false
let hash_224 output input input_len =
[@@ inline_let ]let output:lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get () in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get () in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 output)
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.hash_512
val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512
val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512
let hash_512 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 211, "start_col": 0, "start_line": 201 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_512`. This function is identical to the free function for SHA2_384."; ] let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 64 bytes."]
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_512
Prims.Tot
[ "total" ]
[]
[ "Hacl.Hash.Definitions.hash_t", "Spec.Hash.Definitions.SHA2_512", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.nat", "FStar.Seq.Base.length", "Hacl.Hash.Definitions.hash_len", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.M32", "Lib.MultiBuffer.as_seq_multi", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.unit", "Hacl.Spec.SHA2.Equiv.hash_agile_lemma", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.SHA2.Generic.hash", "Hacl.SHA2.Scalar32.sha512_init", "Hacl.SHA2.Scalar32.sha512_update_nblocks", "Hacl.SHA2.Scalar32.sha512_update_last", "Hacl.SHA2.Scalar32.sha512_finish", "Lib.MultiBuffer.loc_multi1", "Lib.NTuple.ntuple", "Lib.Buffer.lbuffer_t", "Lib.NTuple.ntup1", "Lib.Buffer.lbuffer" ]
[]
false
false
false
true
false
let hash_512 output input input_len =
[@@ inline_let ]let output:lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get () in loc_multi1 rb; hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib; let h1 = ST.get () in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 output)
false
Hacl.GenericField32.fst
Hacl.GenericField32.inverse
val inverse: len:Ghost.erased _ -> MA.bn_field_inv_st t_limbs len
val inverse: len:Ghost.erased _ -> MA.bn_field_inv_st t_limbs len
let inverse len k aM aInvM = MA.bn_field_inv len (exp_vartime len) k aM aInvM
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 64, "start_col": 0, "start_line": 63 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM let from_field len k aM a = let len = field_get_len k in MA.bn_from_field (km len) k aM a let add len k aM bM cM = let len = field_get_len k in MA.bn_field_add (km len) k aM bM cM let sub len k aM bM cM = let len = field_get_len k in MA.bn_field_sub (km len) k aM bM cM let mul len k aM bM cM = let len = field_get_len k in MA.bn_field_mul (km len) k aM bM cM let sqr len k aM cM = let len = field_get_len k in MA.bn_field_sqr (km len) k aM cM let one len k oneM = let len = field_get_len k in MA.bn_field_one (km len) k oneM let exp_consttime len k aM bBits b resM = let len = field_get_len k in MA.bn_field_exp_consttime (km len) k aM bBits b resM let exp_vartime len k aM bBits b resM = let len = field_get_len k in MA.bn_field_exp_vartime (km len) k aM bBits b resM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_field_inv_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Hacl.Bignum.MontArithmetic.bn_field_inv", "Hacl.GenericField32.exp_vartime", "Prims.unit" ]
[]
false
false
false
false
false
let inverse len k aM aInvM =
MA.bn_field_inv len (exp_vartime len) k aM aInvM
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.t64_mod
val t64_mod : Vale.Interop.Base.td
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 41, "start_col": 0, "start_line": 41 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Vale.Interop.Base.default_bq" ]
[]
false
false
false
true
false
let t64_mod =
TD_Buffer TUInt64 TUInt64 default_bq
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.uint64
val uint64 : Prims.eqtype
let uint64 = UInt64.t
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "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": 30 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t" ]
[]
false
false
false
true
false
let uint64 =
UInt64.t
false
Hacl.Streaming.SHA2.fst
Hacl.Streaming.SHA2.hash_384
val hash_384: Hacl.Hash.Definitions.hash_st SHA2_384
val hash_384: Hacl.Hash.Definitions.hash_st SHA2_384
let hash_384 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_384) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_384 #M32 sha384_init sha384_update_nblocks sha384_update_last sha384_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_384 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output)
{ "file_name": "code/streaming/Hacl.Streaming.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 243, "start_col": 0, "start_line": 233 }
module Hacl.Streaming.SHA2 // NOTE: if you get errors trying to load this file in interactive mode because // a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works // totally fine in interactive mode!!), run: // NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked open FStar.HyperStack.ST /// A streaming version of MD-based hashes #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" module G = FStar.Ghost module F = Hacl.Streaming.Functor open Spec.Hash.Definitions open Hacl.Streaming.Interface open Hacl.Streaming.MD /// Instantiations of the streaming functor for specialized SHA2 algorithms. /// /// Some remarks: /// /// - we don't bother with using the abstraction feature since we verified /// clients like miTLS go through EverCrypt.Hash.Incremental inline_for_extraction noextract let hacl_sha2_224 = hacl_md SHA2_224 inline_for_extraction noextract let hacl_sha2_256 = hacl_md SHA2_256 inline_for_extraction noextract let hacl_sha2_384 = hacl_md SHA2_384 inline_for_extraction noextract let hacl_sha2_512 = hacl_md SHA2_512 inline_for_extraction noextract let state_224 = state_t SHA2_224 inline_for_extraction noextract let state_256 = state_t SHA2_256 inline_for_extraction noextract let state_384 = state_t SHA2_384 inline_for_extraction noextract let state_512 = state_t SHA2_512 /// Type abbreviations - for pretty code generation let state_t_224 = Hacl.Streaming.MD.state_32 let state_t_256 = Hacl.Streaming.MD.state_32 let state_t_384 = Hacl.Streaming.MD.state_64 let state_t_512 = Hacl.Streaming.MD.state_64 open Lib.Buffer open Lib.IntTypes open Lib.NTuple open Lib.MultiBuffer open Hacl.Spec.SHA2.Vec open Hacl.SHA2.Scalar32 open Hacl.Impl.SHA2.Generic module ST = FStar.HyperStack.ST // SHA2-256 // -------- inline_for_extraction noextract let alloca_256 = F.alloca hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Allocate initial state for the SHA2_256 hash. The state is to be freed by calling `free_256`."] let malloc_256 = F.malloc hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_256`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_256 = F.copy hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Reset an existing state to the initial hash state with empty data."] let reset_256 = F.reset hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ CInline ] private let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_256` (since the last call to `reset_256`) exceeds 2^61-1 bytes. This function is identical to the update function for SHA2_224."; ] let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 32 bytes. The state remains valid after a call to `digest_256`, meaning the user may feed more data into the hash via `update_256`. (The digest_256 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_256 = F.digest hacl_sha2_256 () (state_256.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_256`. This function is identical to the free function for SHA2_224."] let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 32 bytes."] val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 let hash_256 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-224 // -------- inline_for_extraction noextract let alloca_224 = F.alloca hacl_sha2_224 () (state_224.s ()) (G.erased unit) let malloc_224 = F.malloc hacl_sha2_224 () (state_224.s ()) (G.erased unit) let reset_224 = F.reset hacl_sha2_224 (G.hide ()) (state_224.s ()) (G.erased unit) // We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256. let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state input input_len -> update_224_256 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 28 bytes. The state remains valid after a call to `digest_224`, meaning the user may feed more data into the hash via `update_224`."] let digest_224 = F.digest hacl_sha2_224 () (state_224.s ()) (G.erased unit) let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_256.s ()) (G.erased unit) = fun state -> free_256 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 28 bytes."] val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-512 // -------- inline_for_extraction noextract let alloca_512 = F.alloca hacl_sha2_512 () (state_512.s ()) (G.erased unit) let malloc_512 = F.malloc hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Copies the state passed as argument into a newly allocated state (deep copy). The state is to be freed by calling `free_512`. Cloning the state this way is useful, for instance, if your control-flow diverges and you need to feed more (different) data into the hash in each branch."] let copy_512 = F.copy hacl_sha2_512 () (state_512.s ()) (G.erased unit) let reset_512 = F.reset hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ CInline ] private let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns 0 for success, or 1 if the combined length of all of the data passed to `update_512` (since the last call to `reset_512`) exceeds 2^125-1 bytes. This function is identical to the update function for SHA2_384."; ] let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 64 bytes. The state remains valid after a call to `digest_512`, meaning the user may feed more data into the hash via `update_512`. (The digest_512 function operates on an internal copy of the state and therefore does not invalidate the client-held state `p`.)"] let digest_512 = F.digest hacl_sha2_512 () (state_512.s ()) (G.erased unit) [@@ Comment "Free a state allocated with `malloc_512`. This function is identical to the free function for SHA2_384."; ] let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 64 bytes."] val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 let hash_512 output input input_len = [@inline_let] let output: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get() in loc_multi1 rb; hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib; let h1 = ST.get() in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 output) // SHA2-384 // -------- inline_for_extraction noextract let alloca_384 = F.alloca hacl_sha2_384 () (state_384.s ()) (G.erased unit) let malloc_384 = F.malloc hacl_sha2_384 () (state_384.s ()) (G.erased unit) let reset_384 = F.reset hacl_sha2_384 (G.hide ()) (state_384.s ()) (G.erased unit) let update_384: F.update_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state input input_len -> update_384_512 state input input_len [@@ Comment "Write the resulting hash into `output`, an array of 48 bytes. The state remains valid after a call to `digest_384`, meaning the user may feed more data into the hash via `update_384`."] let digest_384 = F.digest hacl_sha2_384 () (state_384.s ()) (G.erased unit) let free_384: F.free_st hacl_sha2_512 (G.hide ()) (state_512.s ()) (G.erased unit) = fun state -> free_512 state [@@ Comment "Hash `input`, of len `input_len`, into `output`, an array of 48 bytes."]
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.MD.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.SHA2.Scalar32.fst.checked", "Hacl.Impl.SHA2.Generic.fst.checked", "Hacl.Hash.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.SHA2.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.MD", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_384
Prims.Tot
[ "total" ]
[]
[ "Hacl.Hash.Definitions.hash_t", "Spec.Hash.Definitions.SHA2_384", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.U32", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.nat", "FStar.Seq.Base.length", "Hacl.Hash.Definitions.hash_len", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.M32", "Lib.MultiBuffer.as_seq_multi", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.unit", "Hacl.Spec.SHA2.Equiv.hash_agile_lemma", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.SHA2.Generic.hash", "Hacl.SHA2.Scalar32.sha384_init", "Hacl.SHA2.Scalar32.sha384_update_nblocks", "Hacl.SHA2.Scalar32.sha384_update_last", "Hacl.SHA2.Scalar32.sha384_finish", "Lib.MultiBuffer.loc_multi1", "Lib.NTuple.ntuple", "Lib.Buffer.lbuffer_t", "Lib.NTuple.ntup1", "Lib.Buffer.lbuffer" ]
[]
false
false
false
true
false
let hash_384 output input input_len =
[@@ inline_let ]let output:lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_384) = output in let ib = ntup1 input in let rb = ntup1 output in let h0 = ST.get () in loc_multi1 rb; hash #SHA2_384 #M32 sha384_init sha384_update_nblocks sha384_update_last sha384_finish rb input_len ib; let h1 = ST.get () in Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_384 #M32 (v input_len) (as_seq_multi h0 ib); assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 output)
false
Steel.ST.GenArraySwap.fst
Steel.ST.GenArraySwap.array_swap_gen
val array_swap_gen (#t: Type0) (#pts_to: array_pts_to_t t) (index: array_index_t pts_to) (upd: array_upd_t pts_to) (s0: Ghost.erased (Seq.seq t)) (n: SZ.t) (l: SZ.t) : ST (Ghost.erased (Seq.seq t)) (pts_to s0) (fun s -> pts_to s) ( SZ.v n == Seq.length s0 /\ SZ.v l <= SZ.v n ) (fun s -> SZ.v n == Seq.length s0 /\ SZ.v l <= SZ.v n /\ s `Seq.equal` (Seq.slice s0 (SZ.v l) (SZ.v n) `Seq.append` Seq.slice s0 0 (SZ.v l)) )
val array_swap_gen (#t: Type0) (#pts_to: array_pts_to_t t) (index: array_index_t pts_to) (upd: array_upd_t pts_to) (s0: Ghost.erased (Seq.seq t)) (n: SZ.t) (l: SZ.t) : ST (Ghost.erased (Seq.seq t)) (pts_to s0) (fun s -> pts_to s) ( SZ.v n == Seq.length s0 /\ SZ.v l <= SZ.v n ) (fun s -> SZ.v n == Seq.length s0 /\ SZ.v l <= SZ.v n /\ s `Seq.equal` (Seq.slice s0 (SZ.v l) (SZ.v n) `Seq.append` Seq.slice s0 0 (SZ.v l)) )
let array_swap_gen (#t: Type) (#pts_to: array_pts_to_t t) (index: array_index_t pts_to) (upd: array_upd_t pts_to) (s0: Ghost.erased (Seq.seq t)) (n: SZ.t) (l: SZ.t) : ST (Ghost.erased (Seq.seq t)) (pts_to s0) (fun s -> pts_to s) ( SZ.v n == Seq.length s0 /\ SZ.v l <= SZ.v n ) (fun s -> SZ.v n == Seq.length s0 /\ SZ.v l <= SZ.v n /\ s `Seq.equal` (Seq.slice s0 (SZ.v l) (SZ.v n) `Seq.append` Seq.slice s0 0 (SZ.v l)) ) = if l = 0sz || l = n then begin noop (); return s0 end else array_swap_aux index upd s0 n l
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 38, "end_line": 535, "start_col": 0, "start_line": 510 }
module Steel.ST.GenArraySwap open Steel.ST.GenElim module Prf = Steel.ST.GenArraySwap.Proof module R = Steel.ST.Reference let gcd_inv_prop (n0: nat) (l0: nat) (n: nat) (l: nat) (b: bool) : Tot prop = l0 < n0 /\ l < n /\ (Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\ b == (l > 0) [@@__reduce__] let gcd_inv0 (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun n -> exists_ (fun l -> R.pts_to pn full_perm n `star` R.pts_to pl full_perm l `star` pure (gcd_inv_prop (SZ.v n0) (SZ.v l0) (SZ.v n) (SZ.v l) b) )) let gcd_inv (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = gcd_inv0 n0 l0 pn pl b let gcd_post (n0: SZ.t) (l0: SZ.t) (res: SZ.t) : Tot prop = SZ.v l0 < SZ.v n0 /\ SZ.v res == (Prf.mk_bezout (SZ.v n0) (SZ.v l0)).d #push-options "--z3rlimit 16" #restart-solver let gcd (n0: SZ.t) (l0: SZ.t) : ST SZ.t emp (fun _ -> emp) (SZ.v l0 < SZ.v n0) (fun res -> gcd_post n0 l0 res) = let res = R.with_local n0 (fun pn -> R.with_local l0 (fun pl -> noop (); rewrite (gcd_inv0 n0 l0 pn pl (l0 `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l0 `SZ.gt` 0sz)); Steel.ST.Loops.while_loop (gcd_inv n0 l0 pn pl) (fun _ -> let gb = elim_exists () in rewrite (gcd_inv n0 l0 pn pl gb) (gcd_inv0 n0 l0 pn pl gb); let _ = gen_elim () in let l = R.read pl in [@@inline_let] let b = l `SZ.gt` 0sz in noop (); rewrite (gcd_inv0 n0 l0 pn pl b) (gcd_inv n0 l0 pn pl b); return b ) (fun _ -> rewrite (gcd_inv n0 l0 pn pl true) (gcd_inv0 n0 l0 pn pl true); let _ = gen_elim () in let n = R.read pn in let l = R.read pl in [@@inline_let] let l' = SZ.rem n l in R.write pn l; R.write pl l'; rewrite (gcd_inv0 n0 l0 pn pl (l' `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l' `SZ.gt` 0sz)); noop () ); rewrite (gcd_inv n0 l0 pn pl false) (gcd_inv0 n0 l0 pn pl false); let _ = gen_elim () in let res = R.read pn in return res ) ) in elim_pure (gcd_post n0 l0 res); return res #pop-options let array_swap_partial_invariant (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) : GTot prop = n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ i <= bz.d /\ (forall (i': Prf.nat_up_to bz.d) . (forall (j: Prf.nat_up_to bz.q_n) . (i' < i) ==> ( let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 (Prf.jump n l idx) ))) /\ (forall (i': Prf.nat_up_to bz.d) . (forall (j: Prf.nat_up_to bz.q_n) . (i' > i) ==> ( let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 idx ))) let array_swap_inner_invariant_prop (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) (j: nat) (idx: nat) (b: bool) : GTot prop = Prf.array_swap_inner_invariant s0 n l bz s i j idx /\ (b == (j < bz.q_n - 1)) let array_swap_outer_invariant_prop (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) (b: bool) : GTot prop = Prf.array_swap_outer_invariant s0 n l bz s i /\ (b == (i < bz.d)) [@@__reduce__] let array_swap_outer_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (pi: R.ref SZ.t) (i: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop = R.pts_to pi full_perm i `star` pts_to s [@@erasable] noeq type array_swap_outer_invariant_t (t: Type) = { i: SZ.t; s: Ghost.erased (Seq.seq t); } [@@__reduce__] let array_swap_outer_invariant0 (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun w -> array_swap_outer_invariant_body0 pts_to pi w.i w.s `star` pure (array_swap_outer_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v w.i) b) ) let array_swap_outer_invariant (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (b: bool) : Tot vprop = array_swap_outer_invariant0 pts_to n l bz s0 pi b let intro_array_swap_outer_invariant (#opened: _) (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (b: bool) (i: SZ.t) (s: Ghost.erased (Seq.seq t)) : STGhost unit opened (array_swap_outer_invariant_body0 pts_to pi i s) (fun _ -> array_swap_outer_invariant pts_to n l bz s0 pi b) (array_swap_outer_invariant_prop (SZ.v n) (SZ.v l) bz s0 s (SZ.v i) b) (fun _ -> True) = let w = { i = i; s = s; } in rewrite (array_swap_outer_invariant_body0 pts_to pi i s) (array_swap_outer_invariant_body0 pts_to pi w.i w.s); rewrite (array_swap_outer_invariant0 pts_to n l bz s0 pi b) (array_swap_outer_invariant pts_to n l bz s0 pi b) let elim_array_swap_outer_invariant (#opened: _) (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (b: bool) : STGhost (array_swap_outer_invariant_t t) opened (array_swap_outer_invariant pts_to n l bz s0 pi b) (fun w -> array_swap_outer_invariant_body0 pts_to pi w.i w.s) True (fun w -> array_swap_outer_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v w.i) b /\ True // (b == false ==> Ghost.reveal w.s `Seq.equal` (Seq.slice s0 (SZ.v l) (SZ.v n) `Seq.append` Seq.slice s0 0 (SZ.v l))) ) = let w = elim_exists () in let _ = gen_elim () in // Classical.move_requires (array_swap_outer_invariant_prop_end (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v w.i)) b; noop (); w [@@erasable] noeq type array_swap_inner_invariant_t (t: Type) = { j: SZ.t; idx: SZ.t; s: Ghost.erased (Seq.seq t) } [@@__reduce__] let array_swap_inner_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (i: SZ.t) (pj: R.ref SZ.t) (pidx: R.ref SZ.t) (b: bool) (j: SZ.t) (idx: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop = R.pts_to pi full_perm i `star` R.pts_to pj full_perm j `star` R.pts_to pidx full_perm idx `star` pts_to s [@@__reduce__] let array_swap_inner_invariant0 (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (i: SZ.t) (pj: R.ref SZ.t) (pidx: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun w -> array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b w.j w.idx w.s `star` pure (array_swap_inner_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v i) (SZ.v w.j) (SZ.v w.idx) b) ) let array_swap_inner_invariant (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (i: SZ.t) (pj: R.ref SZ.t) (pidx: R.ref SZ.t) (b: bool) : Tot vprop = array_swap_inner_invariant0 pts_to n l bz s0 pi i pj pidx b let intro_array_swap_inner_invariant (#opened: _) (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (i: SZ.t) (pj: R.ref SZ.t) (pidx: R.ref SZ.t) (b: bool) (j: SZ.t) (idx: SZ.t) (s: Ghost.erased (Seq.seq t)) : STGhost unit opened (array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b j idx s) (fun _ -> array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx b) (array_swap_inner_invariant_prop (SZ.v n) (SZ.v l) bz s0 s (SZ.v i) (SZ.v j) (SZ.v idx) b) (fun _ -> True) = let w = { j = j; idx = idx; s = s; } in rewrite (array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b j idx s) (array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b w.j w.idx w.s); rewrite (array_swap_inner_invariant0 pts_to n l bz s0 pi i pj pidx b) (array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx b) let elim_array_swap_inner_invariant (#opened: _) (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (i: SZ.t) (pj: R.ref SZ.t) (pidx: R.ref SZ.t) (b: bool) : STGhost (array_swap_inner_invariant_t t) opened (array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx b) (fun w -> array_swap_inner_invariant_body0 pts_to n l bz s0 pi i pj pidx b w.j w.idx w.s) True (fun w -> array_swap_inner_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v i) (SZ.v w.j) (SZ.v w.idx) b) = let w = elim_exists () in elim_pure _; w inline_for_extraction let impl_jump (n: SZ.t) (l: SZ.t) (idx: SZ.t) : Pure SZ.t (requires ( SZ.v l < SZ.v n /\ SZ.v idx < SZ.v n )) (ensures (fun idx' -> SZ.v idx' == Prf.jump (SZ.v n) (SZ.v l) (SZ.v idx) )) = Prf.jump_if (SZ.v n) (SZ.v l) () (SZ.v idx); [@@inline_let] let nl = n `SZ.sub` l in if idx `SZ.gte` nl then idx `SZ.sub` nl else idx `SZ.add` l #push-options "--z3rlimit 96" #restart-solver inline_for_extraction let array_swap_outer_body (#t: Type) (#pts_to: array_pts_to_t t) (index: array_index_t pts_to) (upd: array_upd_t pts_to) (s0: Ghost.erased (Seq.seq t)) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (d: SZ.t) (q: SZ.t) (pi: R.ref SZ.t) (sq: squash ( SZ.v d == bz.d /\ SZ.v q == bz.q_n )) () : STT unit (array_swap_outer_invariant pts_to n l bz s0 pi true) (fun _ -> exists_ (array_swap_outer_invariant pts_to n l bz s0 pi)) = let _ = elim_array_swap_outer_invariant pts_to n l bz s0 pi true in let _ = gen_elim () in let i = R.read pi in let s = vpattern_replace pts_to in let save = index _ n i in R.with_local 0sz (fun pj -> R.with_local i (fun pidx -> noop (); intro_array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx (0 < bz.q_n - 1) _ _ _; Steel.ST.Loops.while_loop (array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx) (fun _ -> let gb = elim_exists () in let _ = elim_array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx gb in let j = R.read pj in [@@inline_let] let b = j `SZ.lt` (q `SZ.sub` 1sz) in intro_array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx b _ _ _; return b ) (fun _ -> let _ = elim_array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx true in let j = R.read pj in let idx = R.read pidx in let j' = j `SZ.add` 1sz in let idx' = impl_jump n l idx in let x = index _ n idx' in let _ = upd _ n idx x in R.write pj j'; R.write pidx idx'; intro_array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx (SZ.v j' < bz.q_n - 1) _ _ _; noop () ); let _ = elim_array_swap_inner_invariant pts_to n l bz s0 pi i pj pidx false in let idx = R.read pidx in let _ = upd _ n idx save in [@@inline_let] let i' = i `SZ.add` 1sz in R.write pi i'; intro_array_swap_outer_invariant pts_to n l bz s0 pi (i' `SZ.lt` d) _ _; noop () )) #restart-solver inline_for_extraction let array_swap_aux (#t: Type) (#pts_to: array_pts_to_t t) (index: array_index_t pts_to) (upd: array_upd_t pts_to) (s0: Ghost.erased (Seq.seq t)) (n: SZ.t) (l: SZ.t) : ST (Ghost.erased (Seq.seq t)) (pts_to s0) (fun s -> pts_to s) ( SZ.v n == Seq.length s0 /\ SZ.v l > 0 /\ SZ.v l < SZ.v n ) (fun s -> Prf.array_swap_post s0 (SZ.v n) (SZ.v l) s) = let bz = Prf.mk_bezout (SZ.v n) (SZ.v l) in let d = gcd n l in let q = n `SZ.div` d in let s = R.with_local #_ 0sz #_ #(Ghost.erased (Seq.seq t)) #(fun s -> pts_to s `star` pure (Prf.array_swap_post s0 (SZ.v n) (SZ.v l) s)) (fun pi -> intro_array_swap_outer_invariant pts_to n l bz s0 pi true _ _; Steel.ST.Loops.while_loop (array_swap_outer_invariant pts_to n l bz s0 pi) (fun _ -> let gb = elim_exists () in let _ = elim_array_swap_outer_invariant pts_to n l bz s0 pi gb in let i = R.read pi in [@@inline_let] let b = i `SZ.lt` d in intro_array_swap_outer_invariant pts_to n l bz s0 pi b _ _; return b ) (array_swap_outer_body index upd s0 n l bz d q pi ()); let _ = elim_array_swap_outer_invariant pts_to n l bz s0 pi false in return _ ) in elim_pure _; return s #pop-options
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.GenElim.fsti.checked", "Steel.ST.GenArraySwap.Proof.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.GenArraySwap.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.GenArraySwap.Proof", "short_module": "Prf" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
index: Steel.ST.GenArraySwap.array_index_t pts_to -> upd: Steel.ST.GenArraySwap.array_upd_t pts_to -> s0: FStar.Ghost.erased (FStar.Seq.Base.seq t) -> n: FStar.SizeT.t -> l: FStar.SizeT.t -> Steel.ST.Effect.ST (FStar.Ghost.erased (FStar.Seq.Base.seq t))
Steel.ST.Effect.ST
[]
[]
[ "Steel.ST.GenArraySwap.array_pts_to_t", "Steel.ST.GenArraySwap.array_index_t", "Steel.ST.GenArraySwap.array_upd_t", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "FStar.SizeT.t", "Prims.op_BarBar", "Prims.op_Equality", "FStar.SizeT.__uint_to_t", "Steel.ST.Util.return", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.ST.Util.noop", "Prims.bool", "Steel.ST.GenArraySwap.array_swap_aux", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.SizeT.v", "FStar.Seq.Base.length", "FStar.Ghost.reveal", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.l_True", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "FStar.Seq.Base.slice" ]
[]
false
true
false
false
false
let array_swap_gen (#t: Type) (#pts_to: array_pts_to_t t) (index: array_index_t pts_to) (upd: array_upd_t pts_to) (s0: Ghost.erased (Seq.seq t)) (n l: SZ.t) : ST (Ghost.erased (Seq.seq t)) (pts_to s0) (fun s -> pts_to s) (SZ.v n == Seq.length s0 /\ SZ.v l <= SZ.v n) (fun s -> SZ.v n == Seq.length s0 /\ SZ.v l <= SZ.v n /\ s `Seq.equal` ((Seq.slice s0 (SZ.v l) (SZ.v n)) `Seq.append` (Seq.slice s0 0 (SZ.v l)))) =
if l = 0sz || l = n then (noop (); return s0) else array_swap_aux index upd s0 n l
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.b64
val b64 : Type0
let b64 = buf_t TUInt64 TUInt64
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 39, "start_col": 0, "start_line": 39 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.buf_t", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
false
false
true
true
let b64 =
buf_t TUInt64 TUInt64
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.t64_no_mod
val t64_no_mod : Vale.Interop.Base.td
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 105, "end_line": 43, "start_col": 0, "start_line": 43 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Vale.Interop.Base.Mkbuffer_qualifiers", "Vale.Arch.HeapTypes_s.Secret" ]
[]
false
false
false
true
false
let t64_no_mod =
TD_Buffer TUInt64 TUInt64 ({ modified = false; strict_disjointness = false; taint = MS.Secret })
false
Hacl.GenericField32.fst
Hacl.GenericField32.field_init
val field_init: len:BN.meta_len t_limbs -> MA.bn_field_init_st t_limbs len
val field_init: len:BN.meta_len t_limbs -> MA.bn_field_init_st t_limbs len
let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 19, "start_col": 0, "start_line": 18 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs -> Hacl.Bignum.MontArithmetic.bn_field_init_st Hacl.GenericField32.t_limbs len
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "FStar.Monotonic.HyperHeap.rid", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.MontArithmetic.bn_field_init", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__precomp", "Hacl.GenericField32.km", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx" ]
[]
false
false
false
false
false
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.tuint64
val tuint64 : Vale.Interop.Base.td
let tuint64 = TD_Base TUInt64
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 45, "start_col": 0, "start_line": 45 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
false
false
true
false
let tuint64 =
TD_Base TUInt64
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.fsqr_pre
val fsqr_pre:VSig.vale_pre fsqr_dom
val fsqr_pre:VSig.vale_pre fsqr_dom
let fsqr_pre : VSig.vale_pre fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) -> FW.va_req_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out)
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 69, "end_line": 62, "start_col": 0, "start_line": 55 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let fsqr_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.Fsqr.fsqr_dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.Fsqr.b64", "Vale.X64.Decls.va_state", "Vale.Curve25519.X64.FastWide.va_req_Fsqr_stdcall", "Vale.Interop.Assumptions.win", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Prims.prop" ]
[]
false
false
false
true
false
let fsqr_pre:VSig.vale_pre fsqr_dom =
fun (c: V.va_code) (tmp: b64) (f1: b64) (out: b64) (va_s0: V.va_state) -> FW.va_req_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out)
false
Hacl.GenericField32.fst
Hacl.GenericField32.field_modulus_check
val field_modulus_check: len:BN.meta_len t_limbs -> MA.bn_field_check_modulus_st t_limbs len
val field_modulus_check: len:BN.meta_len t_limbs -> MA.bn_field_check_modulus_st t_limbs len
let field_modulus_check len n = MA.bn_field_check_modulus (km len) n
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 16, "start_col": 0, "start_line": 15 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs -> Hacl.Bignum.MontArithmetic.bn_field_check_modulus_st Hacl.GenericField32.t_limbs len
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.MontArithmetic.bn_field_check_modulus", "Hacl.GenericField32.km", "Prims.bool" ]
[]
false
false
false
false
false
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.code_Fsqr
val code_Fsqr : Vale.X64.Decls.va_code
let code_Fsqr = FW.va_code_Fsqr_stdcall IA.win
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 112, "start_col": 0, "start_line": 112 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let fsqr_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fsqr_pre : VSig.vale_pre fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) -> FW.va_req_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) [@__reduce__] noextract let fsqr_post : VSig.vale_post fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FW.va_ens_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) va_s1 f #set-options "--z3rlimit 200" [@__reduce__] noextract let fsqr_lemma' (code:V.va_code) (_win:bool) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fsqr_pre code tmp f1 out va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fsqr_post code tmp f1 out va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer tmp) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) (ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FW.va_lemma_Fsqr_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp; (va_s1, f) (* Prove that fsqr_lemma' has the required type *) noextract let fsqr_lemma = as_t #(VSig.vale_sig_stdcall fsqr_pre fsqr_post) fsqr_lemma'
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.Curve25519.X64.FastWide.va_code_Fsqr_stdcall", "Vale.Interop.Assumptions.win" ]
[]
false
false
false
true
false
let code_Fsqr =
FW.va_code_Fsqr_stdcall IA.win
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.fsqr_post
val fsqr_post:VSig.vale_post fsqr_dom
val fsqr_post:VSig.vale_post fsqr_dom
let fsqr_post : VSig.vale_post fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FW.va_ens_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) va_s1 f
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 113, "end_line": 73, "start_col": 0, "start_line": 65 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let fsqr_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fsqr_pre : VSig.vale_pre fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) -> FW.va_req_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.Fsqr.fsqr_dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.Fsqr.b64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.Curve25519.X64.FastWide.va_ens_Fsqr_stdcall", "Vale.Interop.Assumptions.win", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Prims.prop" ]
[]
false
false
false
true
false
let fsqr_post:VSig.vale_post fsqr_dom =
fun (c: V.va_code) (tmp: b64) (f1: b64) (out: b64) (va_s0: V.va_state) (va_s1: V.va_state) (f: V.va_fuel) -> FW.va_ens_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) va_s1 f
false
Hacl.P256.PrecompTable.fst
Hacl.P256.PrecompTable.precomp_basepoint_table_lemma_w5
val precomp_basepoint_table_lemma_w5: unit -> Lemma (forall (i:nat{i < 32}). precomp_table_acc_inv g_aff 32 precomp_basepoint_table_lseq_w5 i)
val precomp_basepoint_table_lemma_w5: unit -> Lemma (forall (i:nat{i < 32}). precomp_table_acc_inv g_aff 32 precomp_basepoint_table_lseq_w5 i)
let precomp_basepoint_table_lemma_w5 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 32 precomp_basepoint_table_lseq_w5
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 105, "end_line": 291, "start_col": 0, "start_line": 289 }
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15) let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4 let precomp_g_pow2_192_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma () let precomp_g_pow2_192_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_192_table_list_w4 /// window size = 5; precomputed table = [[0]G, [1]G, ..., [31]G] inline_for_extraction noextract let precomp_basepoint_table_list_w5: x:list uint64{FStar.List.Tot.length x = 384} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31) let precomp_basepoint_table_lseq_w5 : LSeq.lseq uint64 384 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); Seq.seq_of_list precomp_basepoint_table_list_w5
{ "checked_file": "/", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 32}). Hacl.P256.PrecompTable.precomp_table_acc_inv Hacl.P256.PrecompTable.g_aff 32 Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5 i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.P256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Spec.P256.PointOps.base_point", "Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
true
false
true
false
false
let precomp_basepoint_table_lemma_w5 () =
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 32 precomp_basepoint_table_lseq_w5
false
Hacl.GenericField32.fst
Hacl.GenericField32.from_field
val from_field: len:Ghost.erased _ -> MA.bn_from_field_st t_limbs len
val from_field: len:Ghost.erased _ -> MA.bn_from_field_st t_limbs len
let from_field len k aM a = let len = field_get_len k in MA.bn_from_field (km len) k aM a
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 33, "start_col": 0, "start_line": 31 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_from_field_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Hacl.Bignum.MontArithmetic.bn_from_field", "Hacl.GenericField32.km", "Prims.unit", "Hacl.GenericField32.field_get_len" ]
[]
false
false
false
false
false
let from_field len k aM a =
let len = field_get_len k in MA.bn_from_field (km len) k aM a
false
Hacl.GenericField32.fst
Hacl.GenericField32.sqr
val sqr: len:Ghost.erased _ -> MA.bn_field_sqr_st t_limbs len
val sqr: len:Ghost.erased _ -> MA.bn_field_sqr_st t_limbs len
let sqr len k aM cM = let len = field_get_len k in MA.bn_field_sqr (km len) k aM cM
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 49, "start_col": 0, "start_line": 47 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM let from_field len k aM a = let len = field_get_len k in MA.bn_from_field (km len) k aM a let add len k aM bM cM = let len = field_get_len k in MA.bn_field_add (km len) k aM bM cM let sub len k aM bM cM = let len = field_get_len k in MA.bn_field_sub (km len) k aM bM cM let mul len k aM bM cM = let len = field_get_len k in MA.bn_field_mul (km len) k aM bM cM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_field_sqr_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Hacl.Bignum.MontArithmetic.bn_field_sqr", "Hacl.GenericField32.km", "Prims.unit", "Hacl.GenericField32.field_get_len" ]
[]
false
false
false
false
false
let sqr len k aM cM =
let len = field_get_len k in MA.bn_field_sqr (km len) k aM cM
false
Hacl.GenericField32.fst
Hacl.GenericField32.sub
val sub: len:Ghost.erased _ -> MA.bn_field_sub_st t_limbs len
val sub: len:Ghost.erased _ -> MA.bn_field_sub_st t_limbs len
let sub len k aM bM cM = let len = field_get_len k in MA.bn_field_sub (km len) k aM bM cM
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 41, "start_col": 0, "start_line": 39 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM let from_field len k aM a = let len = field_get_len k in MA.bn_from_field (km len) k aM a let add len k aM bM cM = let len = field_get_len k in MA.bn_field_add (km len) k aM bM cM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_field_sub_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Hacl.Bignum.MontArithmetic.bn_field_sub", "Hacl.GenericField32.km", "Prims.unit", "Hacl.GenericField32.field_get_len" ]
[]
false
false
false
false
false
let sub len k aM bM cM =
let len = field_get_len k in MA.bn_field_sub (km len) k aM bM cM
false
Hacl.GenericField32.fst
Hacl.GenericField32.one
val one: len:Ghost.erased _ -> MA.bn_field_one_st t_limbs len
val one: len:Ghost.erased _ -> MA.bn_field_one_st t_limbs len
let one len k oneM = let len = field_get_len k in MA.bn_field_one (km len) k oneM
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 53, "start_col": 0, "start_line": 51 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM let from_field len k aM a = let len = field_get_len k in MA.bn_from_field (km len) k aM a let add len k aM bM cM = let len = field_get_len k in MA.bn_field_add (km len) k aM bM cM let sub len k aM bM cM = let len = field_get_len k in MA.bn_field_sub (km len) k aM bM cM let mul len k aM bM cM = let len = field_get_len k in MA.bn_field_mul (km len) k aM bM cM let sqr len k aM cM = let len = field_get_len k in MA.bn_field_sqr (km len) k aM cM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_field_one_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Hacl.Bignum.MontArithmetic.bn_field_one", "Hacl.GenericField32.km", "Prims.unit", "Hacl.GenericField32.field_get_len" ]
[]
false
false
false
false
false
let one len k oneM =
let len = field_get_len k in MA.bn_field_one (km len) k oneM
false
Hacl.GenericField32.fst
Hacl.GenericField32.to_field
val to_field: len:Ghost.erased _ -> MA.bn_to_field_st t_limbs len
val to_field: len:Ghost.erased _ -> MA.bn_to_field_st t_limbs len
let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 29, "start_col": 0, "start_line": 27 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_to_field_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Hacl.Bignum.MontArithmetic.bn_to_field", "Hacl.GenericField32.km", "Prims.unit", "Hacl.GenericField32.field_get_len" ]
[]
false
false
false
false
false
let to_field len k a aM =
let len = field_get_len k in MA.bn_to_field (km len) k a aM
false
Hacl.GenericField32.fst
Hacl.GenericField32.mul
val mul: len:Ghost.erased _ -> MA.bn_field_mul_st t_limbs len
val mul: len:Ghost.erased _ -> MA.bn_field_mul_st t_limbs len
let mul len k aM bM cM = let len = field_get_len k in MA.bn_field_mul (km len) k aM bM cM
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 45, "start_col": 0, "start_line": 43 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM let from_field len k aM a = let len = field_get_len k in MA.bn_from_field (km len) k aM a let add len k aM bM cM = let len = field_get_len k in MA.bn_field_add (km len) k aM bM cM let sub len k aM bM cM = let len = field_get_len k in MA.bn_field_sub (km len) k aM bM cM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_field_mul_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Hacl.Bignum.MontArithmetic.bn_field_mul", "Hacl.GenericField32.km", "Prims.unit", "Hacl.GenericField32.field_get_len" ]
[]
false
false
false
false
false
let mul len k aM bM cM =
let len = field_get_len k in MA.bn_field_mul (km len) k aM bM cM
false
Hacl.GenericField32.fst
Hacl.GenericField32.exp_consttime
val exp_consttime: len:Ghost.erased _ -> MA.bn_field_exp_consttime_st t_limbs len
val exp_consttime: len:Ghost.erased _ -> MA.bn_field_exp_consttime_st t_limbs len
let exp_consttime len k aM bBits b resM = let len = field_get_len k in MA.bn_field_exp_consttime (km len) k aM bBits b resM
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 54, "end_line": 57, "start_col": 0, "start_line": 55 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM let from_field len k aM a = let len = field_get_len k in MA.bn_from_field (km len) k aM a let add len k aM bM cM = let len = field_get_len k in MA.bn_field_add (km len) k aM bM cM let sub len k aM bM cM = let len = field_get_len k in MA.bn_field_sub (km len) k aM bM cM let mul len k aM bM cM = let len = field_get_len k in MA.bn_field_mul (km len) k aM bM cM let sqr len k aM cM = let len = field_get_len k in MA.bn_field_sqr (km len) k aM cM let one len k oneM = let len = field_get_len k in MA.bn_field_one (km len) k oneM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_field_exp_consttime_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Bignum.MontArithmetic.bn_field_exp_consttime", "Hacl.GenericField32.km", "Prims.unit", "Hacl.GenericField32.field_get_len" ]
[]
false
false
false
false
false
let exp_consttime len k aM bBits b resM =
let len = field_get_len k in MA.bn_field_exp_consttime (km len) k aM bBits b resM
false
Hacl.GenericField32.fst
Hacl.GenericField32.add
val add: len:Ghost.erased _ -> MA.bn_field_add_st t_limbs len
val add: len:Ghost.erased _ -> MA.bn_field_add_st t_limbs len
let add len k aM bM cM = let len = field_get_len k in MA.bn_field_add (km len) k aM bM cM
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 37, "start_col": 0, "start_line": 35 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM let from_field len k aM a = let len = field_get_len k in MA.bn_from_field (km len) k aM a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_field_add_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Hacl.Bignum.MontArithmetic.bn_field_add", "Hacl.GenericField32.km", "Prims.unit", "Hacl.GenericField32.field_get_len" ]
[]
false
false
false
false
false
let add len k aM bM cM =
let len = field_get_len k in MA.bn_field_add (km len) k aM bM cM
false
Steel.Channel.Simplex.fst
Steel.Channel.Simplex.recv_availableT
val recv_availableT: #p: sprot -> #q: _ -> cc: chan q -> vs: chan_val -> vr: chan_val -> unit -> SteelT (msg_t p) (sender_ahead cc.chan_chan.recv p cc.chan_chan vs vr) (fun x -> receiver cc (step p x))
val recv_availableT: #p: sprot -> #q: _ -> cc: chan q -> vs: chan_val -> vr: chan_val -> unit -> SteelT (msg_t p) (sender_ahead cc.chan_chan.recv p cc.chan_chan vs vr) (fun x -> receiver cc (step p x))
let recv_availableT (#p:sprot) #q (cc:chan q) (vs vr:chan_val) (_:unit) : SteelT (msg_t p) (sender_ahead cc.chan_chan.recv p cc.chan_chan vs vr) (fun x -> receiver cc (step p x)) = elim_pure (chan_inv_step_p vr vs); gather_r cc.chan_chan.recv vr; elim_pure (in_state_prop p vr); H.write cc.chan_chan.recv vs; H.share cc.chan_chan.recv; assert (vs.chan_prot == p); let vs_msg : msg_t p = vs.chan_msg in intro_pure (in_state_prop (step p vs_msg) vs); intro_exists vs (fun (vs:chan_val) -> pts_to cc.chan_chan.recv half vs `star` in_state_slprop (step p vs_msg) vs); update_trace cc.chan_chan.trace vr vs; intro_chan_inv cc.chan_chan vs; Steel.SpinLock.release cc.chan_lock; vs_msg
{ "file_name": "lib/steel/Steel.Channel.Simplex.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 10, "end_line": 350, "start_col": 0, "start_line": 334 }
(* 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.Channel.Simplex module P = Steel.Channel.Protocol open Steel.SpinLock open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.HigherReference open Steel.FractionalPermission module MRef = Steel.MonotonicHigherReference module H = Steel.HigherReference let sprot = p:prot { more p } noeq type chan_val = { chan_prot : sprot; chan_msg : msg_t chan_prot; chan_ctr : nat } let mref a p = MRef.ref a p let trace_ref (p:prot) = mref (partial_trace_of p) extended_to noeq type chan_t (p:prot) = { send: ref chan_val; recv: ref chan_val; trace: trace_ref p; } let half : perm = half_perm full_perm let step (s:sprot) (x:msg_t s) = step s x let chan_inv_step_p (vrecv vsend:chan_val) : prop = (vsend.chan_prot == step vrecv.chan_prot vrecv.chan_msg /\ vsend.chan_ctr == vrecv.chan_ctr + 1) let chan_inv_step (vrecv vsend:chan_val) : vprop = pure (chan_inv_step_p vrecv vsend) let chan_inv_cond (vsend:chan_val) (vrecv:chan_val) : vprop = if vsend.chan_ctr = vrecv.chan_ctr then pure (vsend == vrecv) else chan_inv_step vrecv vsend let trace_until_prop #p (r:trace_ref p) (vr:chan_val) (tr: partial_trace_of p) : vprop = MRef.pts_to r full_perm tr `star` pure (until tr == step vr.chan_prot vr.chan_msg) let trace_until #p (r:trace_ref p) (vr:chan_val) = h_exists (trace_until_prop r vr) let chan_inv_recv #p (c:chan_t p) (vsend:chan_val) = h_exists (fun (vrecv:chan_val) -> pts_to c.recv half vrecv `star` trace_until c.trace vrecv `star` chan_inv_cond vsend vrecv) let chan_inv #p (c:chan_t p) : vprop = h_exists (fun (vsend:chan_val) -> pts_to c.send half vsend `star` chan_inv_recv c vsend) let intro_chan_inv_cond_eqT (vs vr:chan_val) : Steel unit emp (fun _ -> chan_inv_cond vs vr) (requires fun _ -> vs == vr) (ensures fun _ _ _ -> True) = intro_pure (vs == vs); rewrite_slprop (chan_inv_cond vs vs) (chan_inv_cond vs vr) (fun _ -> ()) let intro_chan_inv_cond_stepT (vs vr:chan_val) : SteelT unit (chan_inv_step vr vs) (fun _ -> chan_inv_cond vs vr) = Steel.Utils.extract_pure (chan_inv_step_p vr vs); rewrite_slprop (chan_inv_step vr vs) (chan_inv_cond vs vr) (fun _ -> ()) let intro_chan_inv_auxT #p (#vs : chan_val) (#vr : chan_val) (c:chan_t p) : SteelT unit (pts_to c.send half vs `star` pts_to c.recv half vr `star` trace_until c.trace vr `star` chan_inv_cond vs vr) (fun _ -> chan_inv c) = intro_exists _ (fun (vr:chan_val) -> pts_to c.recv half vr `star` trace_until c.trace vr `star` chan_inv_cond vs vr); intro_exists _ (fun (vs:chan_val) -> pts_to c.send half vs `star` chan_inv_recv c vs) let intro_chan_inv_stepT #p (c:chan_t p) (vs vr:chan_val) : SteelT unit (pts_to c.send half vs `star` pts_to c.recv half vr `star` trace_until c.trace vr `star` chan_inv_step vr vs) (fun _ -> chan_inv c) = intro_chan_inv_cond_stepT vs vr; intro_chan_inv_auxT c let intro_chan_inv_eqT #p (c:chan_t p) (vs vr:chan_val) : Steel unit (pts_to c.send half vs `star` pts_to c.recv half vr `star` trace_until c.trace vr) (fun _ -> chan_inv c) (requires fun _ -> vs == vr) (ensures fun _ _ _ -> True) = intro_chan_inv_cond_eqT vs vr; intro_chan_inv_auxT c noeq type chan p = { chan_chan : chan_t p; chan_lock : lock (chan_inv chan_chan) } let in_state_prop (p:prot) (vsend:chan_val) : prop = p == step vsend.chan_prot vsend.chan_msg irreducible let next_chan_val (#p:sprot) (x:msg_t p) (vs0:chan_val { in_state_prop p vs0 }) : Tot (vs:chan_val{in_state_prop (step p x) vs /\ chan_inv_step_p vs0 vs}) = { chan_prot = (step vs0.chan_prot vs0.chan_msg); chan_msg = x; chan_ctr = vs0.chan_ctr + 1 } [@@__reduce__] let in_state_slprop (p:prot) (vsend:chan_val) : vprop = pure (in_state_prop p vsend) let in_state (r:ref chan_val) (p:prot) = h_exists (fun (vsend:chan_val) -> pts_to r half vsend `star` in_state_slprop p vsend) let sender #q (c:chan q) (p:prot) = in_state c.chan_chan.send p let receiver #q (c:chan q) (p:prot) = in_state c.chan_chan.recv p let intro_chan_inv #p (c:chan_t p) (v:chan_val) : SteelT unit (pts_to c.send half v `star` pts_to c.recv half v `star` trace_until c.trace v) (fun _ -> chan_inv c) = intro_chan_inv_eqT c v v let chan_val_p (p:prot) = (vs0:chan_val { in_state_prop p vs0 }) let intro_in_state (r:ref chan_val) (p:prot) (v:chan_val_p p) : SteelT unit (pts_to r half v) (fun _ -> in_state r p) = intro_pure (in_state_prop p v); intro_exists v (fun (v:chan_val) -> pts_to r half v `star` in_state_slprop p v) let msg t p = Msg Send unit (fun _ -> p) let init_chan_val (p:prot) = v:chan_val {v.chan_prot == msg unit p} let initial_trace (p:prot) : (q:partial_trace_of p {until q == p}) = { to = p; tr=Waiting p} let intro_trace_until #q (r:trace_ref q) (tr:partial_trace_of q) (v:chan_val) : Steel unit (MRef.pts_to r full_perm tr) (fun _ -> trace_until r v) (requires fun _ -> until tr == step v.chan_prot v.chan_msg) (ensures fun _ _ _ -> True) = intro_pure (until tr == step v.chan_prot v.chan_msg); intro_exists tr (fun (tr:partial_trace_of q) -> MRef.pts_to r full_perm tr `star` pure (until tr == (step v.chan_prot v.chan_msg))); () let chan_t_sr (p:prot) (send recv:ref chan_val) = (c:chan_t p{c.send == send /\ c.recv == recv}) let intro_trace_until_init #p (c:chan_t p) (v:init_chan_val p) : SteelT unit (MRef.pts_to c.trace full_perm (initial_trace p)) (fun _ -> trace_until c.trace v) = intro_pure (until (initial_trace p) == step v.chan_prot v.chan_msg); //TODO: Not sure why I need this rewrite rewrite_slprop (MRef.pts_to c.trace full_perm (initial_trace p) `star` pure (until (initial_trace p) == step v.chan_prot v.chan_msg)) (MRef.pts_to c.trace full_perm (initial_trace p) `star` pure (until (initial_trace p) == step v.chan_prot v.chan_msg)) (fun _ -> ()); intro_exists (initial_trace p) (trace_until_prop c.trace v) let mk_chan (#p:prot) (send recv:ref chan_val) (v:init_chan_val p) : SteelT (chan_t_sr p send recv) (pts_to send half v `star` pts_to recv half v) (fun c -> chan_inv c) = let tr: trace_ref p = MRef.alloc (extended_to #p) (initial_trace p) in let c = Mkchan_t send recv tr in rewrite_slprop (MRef.pts_to tr full_perm (initial_trace p)) (MRef.pts_to c.trace full_perm (initial_trace p)) (fun _ -> ()); intro_trace_until_init c v; rewrite_slprop (pts_to send half v `star` pts_to recv half v) (pts_to c.send half v `star` pts_to c.recv half v) (fun _ -> ()); intro_chan_inv #p c v; let c' : chan_t_sr p send recv = c in rewrite_slprop (chan_inv c) (chan_inv c') (fun _ -> ()); return c' let new_chan (p:prot) : SteelT (chan p) emp (fun c -> sender c p `star` receiver c p) = let q = msg unit p in let v : chan_val = { chan_prot = q; chan_msg = (); chan_ctr = 0 } in let vp : init_chan_val p = v in let send = H.alloc v in let recv = H.alloc v in H.share recv; H.share send; (* TODO: use smt_fallback *) rewrite_slprop (pts_to send (half_perm full_perm) v `star` pts_to send (half_perm full_perm) v `star` pts_to recv (half_perm full_perm) v `star` pts_to recv (half_perm full_perm) v) (pts_to send half vp `star` pts_to send half vp `star` pts_to recv half vp `star` pts_to recv half vp) (fun _ -> ()); let c = mk_chan send recv vp in intro_in_state send p vp; intro_in_state recv p vp; let l = Steel.SpinLock.new_lock (chan_inv c) in let ch = { chan_chan = c; chan_lock = l } in rewrite_slprop (in_state send p) (sender ch p) (fun _ -> ()); rewrite_slprop (in_state recv p) (receiver ch p) (fun _ -> ()); return ch [@@__reduce__] let send_recv_in_sync (r:ref chan_val) (p:prot{more p}) #q (c:chan_t q) (vs vr:chan_val) : vprop = (pts_to c.send half vs `star` pts_to c.recv half vr `star` trace_until c.trace vr `star` pure (vs == vr) `star` in_state r p) [@@__reduce__] let sender_ahead (r:ref chan_val) (p:prot{more p}) #q (c:chan_t q) (vs vr:chan_val) : vprop = (pts_to c.send half vs `star` pts_to c.recv half vr `star` trace_until c.trace vr `star` chan_inv_step vr vs `star` in_state r p) let update_channel (#p:sprot) #q (c:chan_t q) (x:msg_t p) (vs:chan_val) (r:ref chan_val) : SteelT chan_val (pts_to r full_perm vs `star` in_state_slprop p vs) (fun vs' -> pts_to r full_perm vs' `star` (in_state_slprop (step p x) vs' `star` chan_inv_step vs vs')) = elim_pure (in_state_prop p vs); let vs' = next_chan_val x vs in H.write r vs'; intro_pure (in_state_prop (step p x) vs'); intro_pure (chan_inv_step_p vs vs'); return vs' [@@__reduce__] let send_pre_available (p:sprot) #q (c:chan_t q) (vs vr:chan_val) = send_recv_in_sync c.send p c vs vr let gather_r (#p:sprot) (r:ref chan_val) (v:chan_val) : SteelT unit (pts_to r half v `star` in_state r p) (fun _ -> pts_to r full_perm v `star` in_state_slprop p v) = let v' = witness_exists () in H.higher_ref_pts_to_injective_eq #_ #_ #_ #_ #v #_ r; H.gather #_ #_ #half #half #v #v r; rewrite_slprop (pts_to r (sum_perm half half) v) (pts_to r full_perm v) (fun _ -> ()); rewrite_slprop (in_state_slprop p v') (in_state_slprop p v) (fun _ -> ()) let send_available (#p:sprot) #q (cc:chan q) (x:msg_t p) (vs vr:chan_val) (_:unit) : SteelT unit (send_pre_available p #q cc.chan_chan vs vr) (fun _ -> sender cc (step p x)) = Steel.Utils.extract_pure (vs == vr); Steel.Utils.rewrite #_ #(send_recv_in_sync cc.chan_chan.send p cc.chan_chan vs) vr vs; elim_pure (vs == vs); gather_r cc.chan_chan.send vs; let next_vs = update_channel cc.chan_chan x vs cc.chan_chan.send in H.share cc.chan_chan.send; intro_exists next_vs (fun (next_vs:chan_val) -> pts_to cc.chan_chan.send half next_vs `star` in_state_slprop (step p x) next_vs); intro_chan_inv_stepT cc.chan_chan next_vs vs; Steel.SpinLock.release cc.chan_lock let extensible (#p:prot) (x:partial_trace_of p) = P.more x.to let next_msg_t (#p:prot) (x:partial_trace_of p) = P.next_msg_t x.to let next_trace #p (vr:chan_val) (vs:chan_val) (tr:partial_trace_of p) (s:squash (until tr == step vr.chan_prot vr.chan_msg)) (_:squash (chan_inv_step_p vr vs)) : (ts:partial_trace_of p { until ts == step vs.chan_prot vs.chan_msg }) = let msg : next_msg_t tr = vs.chan_msg in assert (extensible tr); extend_partial_trace tr msg let next_trace_st #p (vr:chan_val) (vs:chan_val) (tr:partial_trace_of p) : Steel (extension_of tr) (chan_inv_step vr vs) (fun _ -> emp) (requires fun _ -> until tr == step vr.chan_prot vr.chan_msg) (ensures fun _ ts _ -> until ts == step vs.chan_prot vs.chan_msg) = elim_pure (chan_inv_step_p vr vs); let ts : extension_of tr = next_trace vr vs tr () () in return ts let update_trace #p (r:trace_ref p) (vr:chan_val) (vs:chan_val) : Steel unit (trace_until r vr) (fun _ -> trace_until r vs) (requires fun _ -> chan_inv_step_p vr vs) (ensures fun _ _ _ -> True) = intro_pure (chan_inv_step_p vr vs); let tr = MRef.read_refine r in elim_pure (until tr == step vr.chan_prot vr.chan_msg); let ts : extension_of tr = next_trace_st vr vs tr in MRef.write r ts; intro_pure (until ts == step vs.chan_prot vs.chan_msg); intro_exists ts (fun (ts:partial_trace_of p) -> MRef.pts_to r full_perm ts `star` pure (until ts == step vs.chan_prot vs.chan_msg))
{ "checked_file": "/", "dependencies": [ "Steel.Utils.fst.checked", "Steel.SpinLock.fsti.checked", "Steel.MonotonicHigherReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.HigherReference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "Steel.Channel.Protocol.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.Channel.Simplex.fst" }
[ { "abbrev": true, "full_module": "Steel.HigherReference", "short_module": "H" }, { "abbrev": true, "full_module": "Steel.MonotonicHigherReference", "short_module": "MRef" }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.HigherReference", "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": "Steel.SpinLock", "short_module": null }, { "abbrev": true, "full_module": "Steel.Channel.Protocol", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel.Protocol", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
cc: Steel.Channel.Simplex.chan q -> vs: Steel.Channel.Simplex.chan_val -> vr: Steel.Channel.Simplex.chan_val -> _: Prims.unit -> Steel.Effect.SteelT (Steel.Channel.Protocol.msg_t p)
Steel.Effect.SteelT
[]
[]
[ "Steel.Channel.Simplex.sprot", "Steel.Channel.Simplex.prot", "Steel.Channel.Simplex.chan", "Steel.Channel.Simplex.chan_val", "Prims.unit", "Steel.Channel.Protocol.msg_t", "Steel.SpinLock.release", "Steel.Channel.Simplex.chan_inv", "Steel.Channel.Simplex.__proj__Mkchan__item__chan_chan", "Steel.Channel.Simplex.__proj__Mkchan__item__chan_lock", "Steel.Channel.Simplex.intro_chan_inv", "Steel.Channel.Simplex.update_trace", "Steel.Channel.Simplex.__proj__Mkchan_t__item__trace", "Steel.Effect.Atomic.intro_exists", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.star", "Steel.HigherReference.pts_to", "Steel.Channel.Simplex.__proj__Mkchan_t__item__recv", "Steel.Channel.Simplex.half", "Steel.Channel.Simplex.in_state_slprop", "Steel.Channel.Simplex.step", "Steel.Effect.Common.vprop", "Steel.Effect.Atomic.intro_pure", "Steel.Channel.Simplex.in_state_prop", "Steel.Channel.Simplex.__proj__Mkchan_val__item__chan_msg", "Prims._assert", "Prims.eq2", "Steel.Channel.Simplex.__proj__Mkchan_val__item__chan_prot", "Steel.HigherReference.share", "Steel.FractionalPermission.full_perm", "Steel.HigherReference.write", "Steel.Effect.Atomic.elim_pure", "Steel.Channel.Simplex.gather_r", "Steel.Channel.Simplex.chan_inv_step_p", "Steel.Channel.Simplex.sender_ahead", "Steel.Channel.Simplex.receiver" ]
[]
false
true
false
false
false
let recv_availableT (#p: sprot) #q (cc: chan q) (vs: chan_val) (vr: chan_val) (_: unit) : SteelT (msg_t p) (sender_ahead cc.chan_chan.recv p cc.chan_chan vs vr) (fun x -> receiver cc (step p x)) =
elim_pure (chan_inv_step_p vr vs); gather_r cc.chan_chan.recv vr; elim_pure (in_state_prop p vr); H.write cc.chan_chan.recv vs; H.share cc.chan_chan.recv; assert (vs.chan_prot == p); let vs_msg:msg_t p = vs.chan_msg in intro_pure (in_state_prop (step p vs_msg) vs); intro_exists vs (fun (vs: chan_val) -> (pts_to cc.chan_chan.recv half vs) `star` (in_state_slprop (step p vs_msg) vs)); update_trace cc.chan_chan.trace vr vs; intro_chan_inv cc.chan_chan vs; Steel.SpinLock.release cc.chan_lock; vs_msg
false
Hacl.GenericField32.fst
Hacl.GenericField32.exp_vartime
val exp_vartime: len:Ghost.erased _ -> MA.bn_field_exp_vartime_st t_limbs len
val exp_vartime: len:Ghost.erased _ -> MA.bn_field_exp_vartime_st t_limbs len
let exp_vartime len k aM bBits b resM = let len = field_get_len k in MA.bn_field_exp_vartime (km len) k aM bBits b resM
{ "file_name": "code/bignum/Hacl.GenericField32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 61, "start_col": 0, "start_line": 59 }
module Hacl.GenericField32 open FStar.Mul module BN = Hacl.Bignum module MA = Hacl.Bignum.MontArithmetic module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let km (len:BN.meta_len t_limbs) = BM.mk_runtime_mont len let field_modulus_check len n = MA.bn_field_check_modulus (km len) n let field_init len r n = MA.bn_field_init len (km len).BM.precomp r n let field_free k = MA.bn_field_free k let field_get_len k = MA.bn_field_get_len k let to_field len k a aM = let len = field_get_len k in MA.bn_to_field (km len) k a aM let from_field len k aM a = let len = field_get_len k in MA.bn_from_field (km len) k aM a let add len k aM bM cM = let len = field_get_len k in MA.bn_field_add (km len) k aM bM cM let sub len k aM bM cM = let len = field_get_len k in MA.bn_field_sub (km len) k aM bM cM let mul len k aM bM cM = let len = field_get_len k in MA.bn_field_mul (km len) k aM bM cM let sqr len k aM cM = let len = field_get_len k in MA.bn_field_sqr (km len) k aM cM let one len k oneM = let len = field_get_len k in MA.bn_field_one (km len) k oneM let exp_consttime len k aM bBits b resM = let len = field_get_len k in MA.bn_field_exp_consttime (km len) k aM bBits b resM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Hacl.GenericField32.fst" }
[ { "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", "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", "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
len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs) -> Hacl.Bignum.MontArithmetic.bn_field_exp_vartime_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.GenericField32.t_limbs", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.Ghost.reveal", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Bignum.MontArithmetic.bn_field_exp_vartime", "Hacl.GenericField32.km", "Prims.unit", "Hacl.GenericField32.field_get_len" ]
[]
false
false
false
false
false
let exp_vartime len k aM bBits b resM =
let len = field_get_len k in MA.bn_field_exp_vartime (km len) k aM bBits b resM
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.fsqr2_pre
val fsqr2_pre:VSig.vale_pre fsqr_dom
val fsqr2_pre:VSig.vale_pre fsqr_dom
let fsqr2_pre : VSig.vale_pre fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) -> FW.va_req_Fsqr2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out)
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 69, "end_line": 135, "start_col": 0, "start_line": 128 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let fsqr_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fsqr_pre : VSig.vale_pre fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) -> FW.va_req_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) [@__reduce__] noextract let fsqr_post : VSig.vale_post fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FW.va_ens_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) va_s1 f #set-options "--z3rlimit 200" [@__reduce__] noextract let fsqr_lemma' (code:V.va_code) (_win:bool) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fsqr_pre code tmp f1 out va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fsqr_post code tmp f1 out va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer tmp) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) (ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FW.va_lemma_Fsqr_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp; (va_s1, f) (* Prove that fsqr_lemma' has the required type *) noextract let fsqr_lemma = as_t #(VSig.vale_sig_stdcall fsqr_pre fsqr_post) fsqr_lemma' noextract let code_Fsqr = FW.va_code_Fsqr_stdcall IA.win (* Here's the type expected for the fsqr wrapper *) [@__reduce__] noextract let lowstar_Fsqr_t = assert_norm (List.length fsqr_dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_Fsqr fsqr_dom [] _ _ (W.mk_prediction code_Fsqr fsqr_dom [] (fsqr_lemma code_Fsqr IA.win)) (* Need to rearrange the order of arguments *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.Fsqr.fsqr_dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.Fsqr.b64", "Vale.X64.Decls.va_state", "Vale.Curve25519.X64.FastWide.va_req_Fsqr2_stdcall", "Vale.Interop.Assumptions.win", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Prims.prop" ]
[]
false
false
false
true
false
let fsqr2_pre:VSig.vale_pre fsqr_dom =
fun (c: V.va_code) (tmp: b64) (f1: b64) (out: b64) (va_s0: V.va_state) -> FW.va_req_Fsqr2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out)
false
Hacl.Chacha20.Vec256.fst
Hacl.Chacha20.Vec256.chacha20_core_256
val chacha20_core_256 : Hacl.Meta.Chacha20.Vec.vec_chacha20_core_higher_t Prims.l_True
let chacha20_core_256 = vec_chacha20_core_higher #8 True double_round_256
{ "file_name": "code/chacha20/Hacl.Chacha20.Vec256.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 10, "start_col": 0, "start_line": 10 }
module Hacl.Chacha20.Vec256 open Hacl.Meta.Chacha20.Vec [@CInline] private let double_round_256 = Hacl.Impl.Chacha20.Core32xN.double_round #8 [@CInline]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Meta.Chacha20.Vec.fst.checked", "Hacl.Impl.Chacha20.Vec.fst.checked", "Hacl.Impl.Chacha20.Core32xN.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Chacha20.Vec256.fst" }
[ { "abbrev": false, "full_module": "Hacl.Meta.Chacha20.Vec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Meta.Chacha20.Vec.vec_chacha20_core_higher_t Prims.l_True
Prims.Tot
[ "total" ]
[]
[ "Hacl.Meta.Chacha20.Vec.vec_chacha20_core_higher", "Prims.l_True", "Hacl.Chacha20.Vec256.double_round_256" ]
[]
false
false
false
false
false
let chacha20_core_256 =
vec_chacha20_core_higher #8 True double_round_256
false
Hacl.Chacha20.Vec256.fst
Hacl.Chacha20.Vec256.chacha20_encrypt_256
val chacha20_encrypt_256 : Hacl.Meta.Chacha20.Vec.vec_chacha20_encrypt_higher_t Prims.l_True
let chacha20_encrypt_256 = vec_chacha20_encrypt_higher #8 True chacha20_init_256 chacha20_core_256
{ "file_name": "code/chacha20/Hacl.Chacha20.Vec256.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 98, "end_line": 15, "start_col": 0, "start_line": 15 }
module Hacl.Chacha20.Vec256 open Hacl.Meta.Chacha20.Vec [@CInline] private let double_round_256 = Hacl.Impl.Chacha20.Core32xN.double_round #8 [@CInline] private let chacha20_core_256 = vec_chacha20_core_higher #8 True double_round_256 [@CInline] private let chacha20_init_256 = Hacl.Impl.Chacha20.Vec.chacha20_init #8
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Meta.Chacha20.Vec.fst.checked", "Hacl.Impl.Chacha20.Vec.fst.checked", "Hacl.Impl.Chacha20.Core32xN.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Chacha20.Vec256.fst" }
[ { "abbrev": false, "full_module": "Hacl.Meta.Chacha20.Vec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Meta.Chacha20.Vec.vec_chacha20_encrypt_higher_t Prims.l_True
Prims.Tot
[ "total" ]
[]
[ "Hacl.Meta.Chacha20.Vec.vec_chacha20_encrypt_higher", "Prims.l_True", "Hacl.Chacha20.Vec256.chacha20_init_256", "Hacl.Chacha20.Vec256.chacha20_core_256" ]
[]
false
false
false
false
false
let chacha20_encrypt_256 =
vec_chacha20_encrypt_higher #8 True chacha20_init_256 chacha20_core_256
false
Pulse.Checker.While.fst
Pulse.Checker.While.while_body_comp_typing
val while_body_comp_typing (#g: env) (u: universe) (x: ppname) (ty inv_body: term) (inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) : comp_typing_u g (comp_while_body x inv_body)
val while_body_comp_typing (#g: env) (u: universe) (x: ppname) (ty inv_body: term) (inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) : comp_typing_u g (comp_while_body x inv_body)
let while_body_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term) (inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) : comp_typing_u g (comp_while_body x inv_body) = Metatheory.admit_comp_typing g (comp_while_body x inv_body)
{ "file_name": "lib/steel/pulse/Pulse.Checker.While.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 63, "end_line": 38, "start_col": 0, "start_line": 35 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.While open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory module RU = Pulse.RuntimeUtils let while_cond_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term) (inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) : comp_typing_u g (comp_while_cond x inv_body) = Metatheory.admit_comp_typing g (comp_while_cond x inv_body)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.While.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u25: Pulse.Syntax.Base.universe -> x: Pulse.Syntax.Base.ppname -> ty: Pulse.Syntax.Base.term -> inv_body: Pulse.Syntax.Base.term -> inv_typing: Pulse.Typing.tot_typing g (Pulse.Syntax.Base.tm_exists_sl u25 (Pulse.Syntax.Base.as_binder ty) inv_body) Pulse.Syntax.Base.tm_vprop -> Pulse.Typing.comp_typing_u g (Pulse.Typing.comp_while_body x inv_body)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_exists_sl", "Pulse.Syntax.Base.as_binder", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.Metatheory.Base.admit_comp_typing", "Pulse.Typing.comp_while_body", "Pulse.Typing.comp_typing_u" ]
[]
false
false
false
false
false
let while_body_comp_typing (#g: env) (u: universe) (x: ppname) (ty inv_body: term) (inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) : comp_typing_u g (comp_while_body x inv_body) =
Metatheory.admit_comp_typing g (comp_while_body x inv_body)
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.fsqr2_post
val fsqr2_post:VSig.vale_post fsqr_dom
val fsqr2_post:VSig.vale_post fsqr_dom
let fsqr2_post : VSig.vale_post fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FW.va_ens_Fsqr2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) va_s1 f
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 114, "end_line": 146, "start_col": 0, "start_line": 138 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let fsqr_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fsqr_pre : VSig.vale_pre fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) -> FW.va_req_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) [@__reduce__] noextract let fsqr_post : VSig.vale_post fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FW.va_ens_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) va_s1 f #set-options "--z3rlimit 200" [@__reduce__] noextract let fsqr_lemma' (code:V.va_code) (_win:bool) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fsqr_pre code tmp f1 out va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fsqr_post code tmp f1 out va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer tmp) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) (ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FW.va_lemma_Fsqr_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp; (va_s1, f) (* Prove that fsqr_lemma' has the required type *) noextract let fsqr_lemma = as_t #(VSig.vale_sig_stdcall fsqr_pre fsqr_post) fsqr_lemma' noextract let code_Fsqr = FW.va_code_Fsqr_stdcall IA.win (* Here's the type expected for the fsqr wrapper *) [@__reduce__] noextract let lowstar_Fsqr_t = assert_norm (List.length fsqr_dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_Fsqr fsqr_dom [] _ _ (W.mk_prediction code_Fsqr fsqr_dom [] (fsqr_lemma code_Fsqr IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fsqr2_pre : VSig.vale_pre fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) -> FW.va_req_Fsqr2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.Fsqr.fsqr_dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.Fsqr.b64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.Curve25519.X64.FastWide.va_ens_Fsqr2_stdcall", "Vale.Interop.Assumptions.win", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Prims.prop" ]
[]
false
false
false
true
false
let fsqr2_post:VSig.vale_post fsqr_dom =
fun (c: V.va_code) (tmp: b64) (f1: b64) (out: b64) (va_s0: V.va_state) (va_s1: V.va_state) (f: V.va_fuel) -> FW.va_ens_Fsqr2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) va_s1 f
false
Pulse.Checker.While.fst
Pulse.Checker.While.while_cond_comp_typing
val while_cond_comp_typing (#g: env) (u: universe) (x: ppname) (ty inv_body: term) (inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) : comp_typing_u g (comp_while_cond x inv_body)
val while_cond_comp_typing (#g: env) (u: universe) (x: ppname) (ty inv_body: term) (inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) : comp_typing_u g (comp_while_cond x inv_body)
let while_cond_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term) (inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) : comp_typing_u g (comp_while_cond x inv_body) = Metatheory.admit_comp_typing g (comp_while_cond x inv_body)
{ "file_name": "lib/steel/pulse/Pulse.Checker.While.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 63, "end_line": 33, "start_col": 0, "start_line": 30 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.While open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory module RU = Pulse.RuntimeUtils
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.While.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u13: Pulse.Syntax.Base.universe -> x: Pulse.Syntax.Base.ppname -> ty: Pulse.Syntax.Base.term -> inv_body: Pulse.Syntax.Base.term -> inv_typing: Pulse.Typing.tot_typing g (Pulse.Syntax.Base.tm_exists_sl u13 (Pulse.Syntax.Base.as_binder ty) inv_body) Pulse.Syntax.Base.tm_vprop -> Pulse.Typing.comp_typing_u g (Pulse.Typing.comp_while_cond x inv_body)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_exists_sl", "Pulse.Syntax.Base.as_binder", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.Metatheory.Base.admit_comp_typing", "Pulse.Typing.comp_while_cond", "Pulse.Typing.comp_typing_u" ]
[]
false
false
false
false
false
let while_cond_comp_typing (#g: env) (u: universe) (x: ppname) (ty inv_body: term) (inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) : comp_typing_u g (comp_while_cond x inv_body) =
Metatheory.admit_comp_typing g (comp_while_cond x inv_body)
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.code_Fsqr2
val code_Fsqr2 : Vale.X64.Decls.va_code
let code_Fsqr2 = FW.va_code_Fsqr2_stdcall IA.win
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 185, "start_col": 0, "start_line": 185 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let fsqr_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fsqr_pre : VSig.vale_pre fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) -> FW.va_req_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) [@__reduce__] noextract let fsqr_post : VSig.vale_post fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FW.va_ens_Fsqr_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) va_s1 f #set-options "--z3rlimit 200" [@__reduce__] noextract let fsqr_lemma' (code:V.va_code) (_win:bool) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fsqr_pre code tmp f1 out va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fsqr_post code tmp f1 out va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer tmp) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) (ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FW.va_lemma_Fsqr_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp; (va_s1, f) (* Prove that fsqr_lemma' has the required type *) noextract let fsqr_lemma = as_t #(VSig.vale_sig_stdcall fsqr_pre fsqr_post) fsqr_lemma' noextract let code_Fsqr = FW.va_code_Fsqr_stdcall IA.win (* Here's the type expected for the fsqr wrapper *) [@__reduce__] noextract let lowstar_Fsqr_t = assert_norm (List.length fsqr_dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_Fsqr fsqr_dom [] _ _ (W.mk_prediction code_Fsqr fsqr_dom [] (fsqr_lemma code_Fsqr IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fsqr2_pre : VSig.vale_pre fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) -> FW.va_req_Fsqr2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) [@__reduce__] noextract let fsqr2_post : VSig.vale_post fsqr_dom = fun (c:V.va_code) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FW.va_ens_Fsqr2_stdcall c va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) va_s1 f #set-options "--z3rlimit 200" [@__reduce__] noextract let fsqr2_lemma' (code:V.va_code) (_win:bool) (tmp:b64) (f1:b64) (out:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fsqr2_pre code tmp f1 out va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fsqr2_post code tmp f1 out va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer tmp) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer tmp) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) (ME.loc_union (ME.loc_buffer (as_vale_buffer tmp)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FW.va_lemma_Fsqr2_stdcall code va_s0 IA.win (as_vale_buffer tmp) (as_vale_buffer f1) (as_vale_buffer out) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 tmp; (va_s1, f) (* Prove that fsqr2_lemma' has the required type *) noextract let fsqr2_lemma = as_t #(VSig.vale_sig_stdcall fsqr2_pre fsqr2_post) fsqr2_lemma'
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.Curve25519.X64.FastWide.va_code_Fsqr2_stdcall", "Vale.Interop.Assumptions.win" ]
[]
false
false
false
true
false
let code_Fsqr2 =
FW.va_code_Fsqr2_stdcall IA.win
false
Hacl.Chacha20.Vec256.fst
Hacl.Chacha20.Vec256.chacha20_init_256
val chacha20_init_256 : ctx: Hacl.Impl.Chacha20.Core32xN.state 8 -> k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 12ul -> ctr0: Lib.IntTypes.size_t -> FStar.HyperStack.ST.Stack Prims.unit
let chacha20_init_256 = Hacl.Impl.Chacha20.Vec.chacha20_init #8
{ "file_name": "code/chacha20/Hacl.Chacha20.Vec256.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 63, "end_line": 13, "start_col": 0, "start_line": 13 }
module Hacl.Chacha20.Vec256 open Hacl.Meta.Chacha20.Vec [@CInline] private let double_round_256 = Hacl.Impl.Chacha20.Core32xN.double_round #8 [@CInline] private let chacha20_core_256 = vec_chacha20_core_higher #8 True double_round_256 [@CInline]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Meta.Chacha20.Vec.fst.checked", "Hacl.Impl.Chacha20.Vec.fst.checked", "Hacl.Impl.Chacha20.Core32xN.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Chacha20.Vec256.fst" }
[ { "abbrev": false, "full_module": "Hacl.Meta.Chacha20.Vec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ctx: Hacl.Impl.Chacha20.Core32xN.state 8 -> k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 12ul -> ctr0: Lib.IntTypes.size_t -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Vec.chacha20_init" ]
[]
false
true
false
false
false
let chacha20_init_256 =
Hacl.Impl.Chacha20.Vec.chacha20_init #8
false
Hacl.Chacha20.Vec256.fst
Hacl.Chacha20.Vec256.double_round_256
val double_round_256 : st: Hacl.Impl.Chacha20.Core32xN.state 8 -> FStar.HyperStack.ST.Stack Prims.unit
let double_round_256 = Hacl.Impl.Chacha20.Core32xN.double_round #8
{ "file_name": "code/chacha20/Hacl.Chacha20.Vec256.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 66, "end_line": 7, "start_col": 0, "start_line": 7 }
module Hacl.Chacha20.Vec256 open Hacl.Meta.Chacha20.Vec [@CInline]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Hacl.Meta.Chacha20.Vec.fst.checked", "Hacl.Impl.Chacha20.Vec.fst.checked", "Hacl.Impl.Chacha20.Core32xN.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Chacha20.Vec256.fst" }
[ { "abbrev": false, "full_module": "Hacl.Meta.Chacha20.Vec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Chacha20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
st: Hacl.Impl.Chacha20.Core32xN.state 8 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32xN.double_round" ]
[]
false
true
false
false
false
let double_round_256 =
Hacl.Impl.Chacha20.Core32xN.double_round #8
false
Vale.Stdcalls.X64.Fsqr.fsti
Vale.Stdcalls.X64.Fsqr.as_normal_t
val as_normal_t (#a: Type) (x: a) : normal a
val as_normal_t (#a: Type) (x: a) : normal a
let as_normal_t (#a:Type) (x:a) : normal a = x
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fsqr.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 36, "start_col": 0, "start_line": 36 }
module Vale.Stdcalls.X64.Fsqr open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.Fsqr.fsti" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Vale.Interop.Base.normal a
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.normal" ]
[]
false
false
false
true
false
let as_normal_t (#a: Type) (x: a) : normal a =
x
false