effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Pure
val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let logxor x y = Mk (logxor (v x) (v y))
val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) let logxor x y =
false
null
false
Mk (logxor (v x) (v y))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "FStar.UInt8.Mk", "FStar.UInt.logxor", "FStar.UInt8.n", "FStar.UInt8.v" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z))
[]
FStar.UInt8.logxor
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 40, "end_line": 66, "start_col": 17, "start_line": 66 }
Prims.Pure
val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let uint_to_t x = Mk x
val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) let uint_to_t x =
false
null
false
Mk x
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt.uint_t", "FStar.UInt8.n", "FStar.UInt8.Mk", "FStar.UInt8.t" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x))
[]
FStar.UInt8.uint_to_t
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt.uint_t FStar.UInt8.n -> Prims.Pure FStar.UInt8.t
{ "end_col": 22, "end_line": 30, "start_col": 18, "start_line": 30 }
Prims.Pure
val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let logor x y = Mk (logor (v x) (v y))
val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) let logor x y =
false
null
false
Mk (logor (v x) (v y))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "FStar.UInt8.Mk", "FStar.UInt.logor", "FStar.UInt8.n", "FStar.UInt8.v" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z))
[]
FStar.UInt8.logor
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 38, "end_line": 68, "start_col": 16, "start_line": 68 }
Prims.Pure
val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let lognot x = Mk (lognot (v x))
val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) let lognot x =
false
null
false
Mk (lognot (v x))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "FStar.UInt8.Mk", "FStar.UInt.lognot", "FStar.UInt8.n", "FStar.UInt8.v" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z))
[]
FStar.UInt8.lognot
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 32, "end_line": 70, "start_col": 15, "start_line": 70 }
Prims.Pure
val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let sub_mod a b = Mk (sub_mod (v a) (v b))
val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) let sub_mod a b =
false
null
false
Mk (sub_mod (v a) (v b))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "FStar.UInt8.Mk", "FStar.UInt.sub_mod", "FStar.UInt8.n", "FStar.UInt8.v" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
[]
FStar.UInt8.sub_mod
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 42, "end_line": 52, "start_col": 18, "start_line": 52 }
Prims.Pure
val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let add_mod a b = Mk (add_mod (v a) (v b))
val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) let add_mod a b =
false
null
false
Mk (add_mod (v a) (v b))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "FStar.UInt8.Mk", "FStar.UInt.add_mod", "FStar.UInt8.n", "FStar.UInt8.v" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
[]
FStar.UInt8.add_mod
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 42, "end_line": 46, "start_col": 18, "start_line": 46 }
Prims.Pure
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let rem a b = Mk (mod (v a) (v b))
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) let rem a b =
false
null
false
Mk (mod (v a) (v b))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "FStar.UInt8.v", "FStar.UInt8.Mk", "FStar.UInt.mod", "FStar.UInt8.n" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
[]
FStar.UInt8.rem
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.UInt8.t{FStar.UInt8.v b <> 0} -> Prims.Pure FStar.UInt8.t
{ "end_col": 34, "end_line": 62, "start_col": 14, "start_line": 62 }
Prims.Pure
val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let shift_right a s = Mk (shift_right (v a) (UInt32.v s))
val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) let shift_right a s =
false
null
false
Mk (shift_right (v a) (UInt32.v s))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "FStar.UInt32.t", "FStar.UInt8.Mk", "FStar.UInt.shift_right", "FStar.UInt8.n", "FStar.UInt8.v", "FStar.UInt32.v" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y)) let lognot x = Mk (lognot (v x))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
[]
FStar.UInt8.shift_right
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 57, "end_line": 72, "start_col": 22, "start_line": 72 }
Prims.Pure
val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let mul_mod a b = Mk (mul_mod (v a) (v b))
val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) let mul_mod a b =
false
null
false
Mk (mul_mod (v a) (v b))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "FStar.UInt8.Mk", "FStar.UInt.mul_mod", "FStar.UInt8.n", "FStar.UInt8.v" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
[]
FStar.UInt8.mul_mod
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 42, "end_line": 58, "start_col": 18, "start_line": 58 }
Prims.Pure
val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let logand x y = Mk (logand (v x) (v y))
val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) let logand x y =
false
null
false
Mk (logand (v x) (v y))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "FStar.UInt8.Mk", "FStar.UInt.logand", "FStar.UInt8.n", "FStar.UInt8.v" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z))
[]
FStar.UInt8.logand
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 40, "end_line": 64, "start_col": 17, "start_line": 64 }
Prims.Pure
val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let shift_left a s = Mk (shift_left (v a) (UInt32.v s))
val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) let shift_left a s =
false
null
false
Mk (shift_left (v a) (UInt32.v s))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "FStar.UInt32.t", "FStar.UInt8.Mk", "FStar.UInt.shift_left", "FStar.UInt8.n", "FStar.UInt8.v", "FStar.UInt32.v" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y)) let lognot x = Mk (lognot (v x)) let shift_right a s = Mk (shift_right (v a) (UInt32.v s)) #push-options "--z3rlimit 80 --fuel 1" //AR: working around the interleaving semantics of pragmas
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 80, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
[]
FStar.UInt8.shift_left
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 55, "end_line": 76, "start_col": 21, "start_line": 76 }
Prims.Pure
val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let div a b = Mk (div (v a) (v b))
val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) let div a b =
false
null
false
Mk (div (v a) (v b))
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[]
[ "FStar.UInt8.t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "FStar.UInt8.v", "FStar.UInt8.Mk", "FStar.UInt.div", "FStar.UInt8.n" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c))
[]
FStar.UInt8.div
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.UInt8.t{FStar.UInt8.v b <> 0} -> Prims.Pure FStar.UInt8.t
{ "end_col": 34, "end_line": 60, "start_col": 14, "start_line": 60 }
FStar.Pervasives.Lemma
val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "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 } ]
false
let lemma_sub_msbs a b = from_vec_propriety (to_vec (v a)) 1; from_vec_propriety (to_vec (v b)) 1; from_vec_propriety (to_vec (v (sub_mod a b))) 1
val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) let lemma_sub_msbs a b =
false
null
true
from_vec_propriety (to_vec (v a)) 1; from_vec_propriety (to_vec (v b)) 1; from_vec_propriety (to_vec (v (sub_mod a b))) 1
{ "checked_file": "FStar.UInt8.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt8.fst" }
[ "lemma" ]
[ "FStar.UInt8.t", "FStar.UInt.from_vec_propriety", "FStar.UInt8.n", "FStar.UInt.to_vec", "FStar.UInt8.v", "FStar.UInt8.sub_mod", "Prims.unit" ]
[]
(* Copyright 2008-2019 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.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y)) let lognot x = Mk (lognot (v x)) let shift_right a s = Mk (shift_right (v a) (UInt32.v s)) #push-options "--z3rlimit 80 --fuel 1" //AR: working around the interleaving semantics of pragmas let shift_left a s = Mk (shift_left (v a) (UInt32.v s))
false
false
FStar.UInt8.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 80, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
[]
FStar.UInt8.lemma_sub_msbs
{ "file_name": "ulib/FStar.UInt8.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.UInt8.t -> FStar.Pervasives.Lemma (ensures FStar.UInt.msb (FStar.UInt8.v a) = FStar.UInt.msb (FStar.UInt8.v b) ==> (FStar.UInt8.v a < FStar.UInt8.v b <==> FStar.UInt.msb (FStar.UInt8.v (FStar.UInt8.sub_mod a b))))
{ "end_col": 53, "end_line": 81, "start_col": 6, "start_line": 79 }
Prims.Tot
val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True
val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f =
false
null
false
match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[ "total" ]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.Curve25519.Fields.Core.felem", "Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Prims.l_True" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0
[]
Hacl.Impl.Curve25519.Finv.fsquare_times_inv
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Curve25519.Fields.Core.felem s -> Type0
{ "end_col": 15, "end_line": 26, "start_col": 2, "start_line": 24 }
Prims.Tot
val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fmuls_pre #s h f1 f2 = match s with | M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1) | M64 -> True
val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0 let fmuls_pre #s h f1 f2 =
false
null
false
match s with | M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1) | M64 -> True
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[ "total" ]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.Curve25519.Fields.Core.felem", "Prims.l_and", "Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Prims.l_True" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) [@ Meta.Attribute.inline_ ] let fsqr_s #s out f1 tmp = C.fsqr #s out f1 tmp noextract val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0
[]
Hacl.Impl.Curve25519.Finv.fmuls_pre
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> f1: Hacl.Impl.Curve25519.Fields.Core.felem s -> f2: Hacl.Impl.Curve25519.Fields.Core.felem s -> Type0
{ "end_col": 15, "end_line": 55, "start_col": 2, "start_line": 53 }
FStar.HyperStack.ST.Stack
val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fsqr_s #s out f1 tmp = C.fsqr #s out f1 tmp
val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) let fsqr_s #s out f1 tmp =
true
null
false
C.fsqr #s out f1 tmp
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Hacl.Impl.Curve25519.Fields.Core.felem", "Hacl.Impl.Curve25519.Fields.Core.felem_wide", "Hacl.Impl.Curve25519.Fields.Core.fsqr", "Prims.unit" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) [@ Meta.Attribute.inline_ ]
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1))
[]
Hacl.Impl.Curve25519.Finv.fsqr_s
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Impl.Curve25519.Fields.Core.felem s -> f1: Hacl.Impl.Curve25519.Fields.Core.felem s -> tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide s -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 22, "end_line": 47, "start_col": 2, "start_line": 47 }
FStar.HyperStack.ST.Stack
val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fmul_s #s out f1 f2 tmp = C.fmul #s out f1 f2 tmp
val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2)) let fmul_s #s out f1 f2 tmp =
true
null
false
C.fmul #s out f1 f2 tmp
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Hacl.Impl.Curve25519.Fields.Core.felem", "Hacl.Impl.Curve25519.Fields.Core.felem_wide2", "Hacl.Impl.Curve25519.Fields.Core.fmul", "Prims.unit" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) [@ Meta.Attribute.inline_ ] let fsqr_s #s out f1 tmp = C.fsqr #s out f1 tmp noextract val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0 let fmuls_pre #s h f1 f2 = match s with | M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1) | M64 -> True val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2)) [@ Meta.Attribute.inline_ ]
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[]
Hacl.Impl.Curve25519.Finv.fmul_s
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Impl.Curve25519.Fields.Core.felem s -> f1: Hacl.Impl.Curve25519.Fields.Core.felem s -> f2: Hacl.Impl.Curve25519.Fields.Core.felem s -> tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 25, "end_line": 79, "start_col": 2, "start_line": 79 }
FStar.HyperStack.ST.Stack
val fsquare_times: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide s -> n:size_t{v n > 0} -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ (disjoint o i \/ o == i) /\ disjoint o tmp /\ disjoint tmp i /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == S.pow (feval #s h0 i) (pow2 (v n)))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fsquare_times #s o inp tmp n = let h0 = ST.get() in fsqr_s #s o inp tmp; S.lemma_pow_one (feval h0 inp); S.lemma_pow_add (feval h0 inp) 1 1; assert_norm (pow2 1 = 2); let inv (h:mem) (i:nat{i < v n}) = modifies (loc o |+| loc tmp) h0 h /\ fsquare_times_inv #s h o /\ feval h o == S.pow (feval #s h0 inp) (pow2 (i + 1)) in let h1 = ST.get () in assert (inv h1 0); Lib.Loops.for 0ul (n -! 1ul) inv (fun i -> let h2 = ST.get () in fsqr_s #s o o tmp; S.lemma_pow_add (feval #s h0 inp) (pow2 (v i + 1)) (pow2 (v i + 1)); Math.Lemmas.pow2_double_sum (v i + 1))
val fsquare_times: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide s -> n:size_t{v n > 0} -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ (disjoint o i \/ o == i) /\ disjoint o tmp /\ disjoint tmp i /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == S.pow (feval #s h0 i) (pow2 (v n))) let fsquare_times #s o inp tmp n =
true
null
false
let h0 = ST.get () in fsqr_s #s o inp tmp; S.lemma_pow_one (feval h0 inp); S.lemma_pow_add (feval h0 inp) 1 1; assert_norm (pow2 1 = 2); let inv (h: mem) (i: nat{i < v n}) = modifies (loc o |+| loc tmp) h0 h /\ fsquare_times_inv #s h o /\ feval h o == S.pow (feval #s h0 inp) (pow2 (i + 1)) in let h1 = ST.get () in assert (inv h1 0); Lib.Loops.for 0ul (n -! 1ul) inv (fun i -> let h2 = ST.get () in fsqr_s #s o o tmp; S.lemma_pow_add (feval #s h0 inp) (pow2 (v i + 1)) (pow2 (v i + 1)); Math.Lemmas.pow2_double_sum (v i + 1))
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Hacl.Impl.Curve25519.Fields.Core.felem", "Hacl.Impl.Curve25519.Fields.Core.felem_wide", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Loops.for", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Subtraction_Bang", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "FStar.Math.Lemmas.pow2_double_sum", "Prims.op_Addition", "Prims.unit", "Hacl.Spec.Curve25519.Finv.lemma_pow_add", "Hacl.Impl.Curve25519.Fields.Core.feval", "Prims.pow2", "Hacl.Impl.Curve25519.Finv.fsqr_s", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims._assert", "Prims.nat", "Prims.logical", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Lib.Buffer.MUT", "Hacl.Impl.Curve25519.Fields.Core.limb", "Hacl.Impl.Curve25519.Fields.Core.wide", "Hacl.Impl.Curve25519.Finv.fsquare_times_inv", "Prims.eq2", "Spec.Curve25519.elem", "Hacl.Spec.Curve25519.Finv.pow", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "Hacl.Spec.Curve25519.Finv.lemma_pow_one" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) [@ Meta.Attribute.inline_ ] let fsqr_s #s out f1 tmp = C.fsqr #s out f1 tmp noextract val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0 let fmuls_pre #s h f1 f2 = match s with | M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1) | M64 -> True val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2)) [@ Meta.Attribute.inline_ ] let fmul_s #s out f1 f2 tmp = C.fmul #s out f1 f2 tmp val fsquare_times: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide s -> n:size_t{v n > 0} -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ (disjoint o i \/ o == i) /\ disjoint o tmp /\ disjoint tmp i /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == S.pow (feval #s h0 i) (pow2 (v n)))
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fsquare_times: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide s -> n:size_t{v n > 0} -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ (disjoint o i \/ o == i) /\ disjoint o tmp /\ disjoint tmp i /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == S.pow (feval #s h0 i) (pow2 (v n)))
[]
Hacl.Impl.Curve25519.Finv.fsquare_times
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Hacl.Impl.Curve25519.Fields.Core.felem s -> i: Hacl.Impl.Curve25519.Fields.Core.felem s -> tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide s -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n > 0} -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 42, "end_line": 120, "start_col": 34, "start_line": 100 }
FStar.HyperStack.ST.Stack
val finv3: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs /\ fsquare_times_inv h0 cs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let ts0 : felem s = gsub t1 (3ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 cs) 100 in let t0 = P.fmul t0 (feval h0 cs) in let t0 = S.fsquare_times t0 50 in let t0 = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times t0 5 in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 ts0 == t0 /\ fsquare_times_inv h1 ts0))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finv3 #s t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2^200 - 2^100 *) fsquare_times #s t0 c tmp1 100ul; (* 2^200 - 2^0 *) fmul_s #s t0 t0 c tmp; (* 2^250 - 2^50 *) fsquare_times #s t0 t0 tmp1 50ul; (* 2^250 - 2^0 *) fmul_s #s t0 t0 b tmp; (* 2^255 - 2^5 *) fsquare_times #s t0 t0 tmp1 5ul
val finv3: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs /\ fsquare_times_inv h0 cs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let ts0 : felem s = gsub t1 (3ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 cs) 100 in let t0 = P.fmul t0 (feval h0 cs) in let t0 = S.fsquare_times t0 50 in let t0 = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times t0 5 in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 ts0 == t0 /\ fsquare_times_inv h1 ts0)) let finv3 #s t1 tmp =
true
null
false
let h0 = ST.get () in let a:felem s = sub t1 0ul (nlimb s) in let b:felem s = sub t1 (nlimb s) (nlimb s) in let c:felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0:felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1:felem_wide s = sub tmp 0ul (nwide s) in fsquare_times #s t0 c tmp1 100ul; fmul_s #s t0 t0 c tmp; fsquare_times #s t0 t0 tmp1 50ul; fmul_s #s t0 t0 b tmp; fsquare_times #s t0 t0 tmp1 5ul
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Lib.Buffer.lbuffer", "Hacl.Impl.Curve25519.Fields.Core.limb", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Curve25519.Fields.Core.nlimb", "Hacl.Impl.Curve25519.Fields.Core.felem_wide2", "Hacl.Impl.Curve25519.Finv.fsquare_times", "Prims.unit", "Hacl.Impl.Curve25519.Finv.fmul_s", "Hacl.Impl.Curve25519.Fields.Core.felem_wide", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Hacl.Impl.Curve25519.Fields.Core.wide", "Lib.IntTypes.op_Plus_Dot", "Hacl.Impl.Curve25519.Fields.Core.nwide", "Lib.Buffer.lbuffer_t", "Hacl.Impl.Curve25519.Fields.Core.felem", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) [@ Meta.Attribute.inline_ ] let fsqr_s #s out f1 tmp = C.fsqr #s out f1 tmp noextract val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0 let fmuls_pre #s h f1 f2 = match s with | M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1) | M64 -> True val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2)) [@ Meta.Attribute.inline_ ] let fmul_s #s out f1 f2 tmp = C.fmul #s out f1 f2 tmp val fsquare_times: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide s -> n:size_t{v n > 0} -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ (disjoint o i \/ o == i) /\ disjoint o tmp /\ disjoint tmp i /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == S.pow (feval #s h0 i) (pow2 (v n))) [@ Meta.Attribute.specialize ] let fsquare_times #s o inp tmp n = let h0 = ST.get() in fsqr_s #s o inp tmp; S.lemma_pow_one (feval h0 inp); S.lemma_pow_add (feval h0 inp) 1 1; assert_norm (pow2 1 = 2); let inv (h:mem) (i:nat{i < v n}) = modifies (loc o |+| loc tmp) h0 h /\ fsquare_times_inv #s h o /\ feval h o == S.pow (feval #s h0 inp) (pow2 (i + 1)) in let h1 = ST.get () in assert (inv h1 0); Lib.Loops.for 0ul (n -! 1ul) inv (fun i -> let h2 = ST.get () in fsqr_s #s o o tmp; S.lemma_pow_add (feval #s h0 inp) (pow2 (v i + 1)) (pow2 (v i + 1)); Math.Lemmas.pow2_double_sum (v i + 1)) val finv1: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let a = S.fsquare_times (feval h0 i) 1 in let t0 = S.fsquare_times a 2 in let b = P.fmul t0 (feval h0 i) in let a = P.fmul b a in let t0 = S.fsquare_times a 1 in let b = P.fmul t0 b in let t0 = S.fsquare_times b 5 in let b = P.fmul t0 b in feval h1 as0 == a /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs)) [@ Meta.Attribute.inline_ ] let finv1 #s i t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2 *) fsquare_times #s a i tmp1 1ul; (* 8 *) fsquare_times #s t0 a tmp1 2ul; (* 9 *) fmul_s #s b t0 i tmp; (* 11 *) fmul_s #s a b a tmp; (* 22 *) fsquare_times #s t0 a tmp1 1ul; (* 2^5 - 2^0 = 31 *) fmul_s #s b t0 b tmp; (* 2^10 - 2^5 *) fsquare_times #s t0 b tmp1 5ul; (* 2^10 - 2^0 *) fmul_s #s b t0 b tmp val finv2: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 bs) 10 in let c = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times c 20 in let t0 = P.fmul t0 c in let t0 = S.fsquare_times t0 10 in let b = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times b 50 in let c = P.fmul t0 b in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs /\ feval h1 cs == c /\ fsquare_times_inv h1 cs)) [@ Meta.Attribute.inline_ ] let finv2 #s t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2^20 - 2^10 *) fsquare_times #s t0 b tmp1 10ul; (* 2^20 - 2^0 *) fmul_s #s c t0 b tmp; (* 2^40 - 2^20 *) fsquare_times #s t0 c tmp1 20ul; (* 2^40 - 2^0 *) fmul_s #s t0 t0 c tmp; (* 2^50 - 2^10 *) fsquare_times #s t0 t0 tmp1 10ul; (* 2^50 - 2^0 *) fmul_s #s b t0 b tmp; (* 2^100 - 2^50 *) fsquare_times #s t0 b tmp1 50ul; (* 2^100 - 2^0 *) fmul_s #s c t0 b tmp val finv3: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs /\ fsquare_times_inv h0 cs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let ts0 : felem s = gsub t1 (3ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 cs) 100 in let t0 = P.fmul t0 (feval h0 cs) in let t0 = S.fsquare_times t0 50 in let t0 = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times t0 5 in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 ts0 == t0 /\ fsquare_times_inv h1 ts0))
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finv3: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs /\ fsquare_times_inv h0 cs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let ts0 : felem s = gsub t1 (3ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 cs) 100 in let t0 = P.fmul t0 (feval h0 cs) in let t0 = S.fsquare_times t0 50 in let t0 = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times t0 5 in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 ts0 == t0 /\ fsquare_times_inv h1 ts0))
[]
Hacl.Impl.Curve25519.Finv.finv3
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t1: Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s) (4ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s) -> tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 51, "end_line": 249, "start_col": 21, "start_line": 238 }
FStar.HyperStack.ST.Stack
val finv1: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let a = S.fsquare_times (feval h0 i) 1 in let t0 = S.fsquare_times a 2 in let b = P.fmul t0 (feval h0 i) in let a = P.fmul b a in let t0 = S.fsquare_times a 1 in let b = P.fmul t0 b in let t0 = S.fsquare_times b 5 in let b = P.fmul t0 b in feval h1 as0 == a /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finv1 #s i t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2 *) fsquare_times #s a i tmp1 1ul; (* 8 *) fsquare_times #s t0 a tmp1 2ul; (* 9 *) fmul_s #s b t0 i tmp; (* 11 *) fmul_s #s a b a tmp; (* 22 *) fsquare_times #s t0 a tmp1 1ul; (* 2^5 - 2^0 = 31 *) fmul_s #s b t0 b tmp; (* 2^10 - 2^5 *) fsquare_times #s t0 b tmp1 5ul; (* 2^10 - 2^0 *) fmul_s #s b t0 b tmp
val finv1: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let a = S.fsquare_times (feval h0 i) 1 in let t0 = S.fsquare_times a 2 in let b = P.fmul t0 (feval h0 i) in let a = P.fmul b a in let t0 = S.fsquare_times a 1 in let b = P.fmul t0 b in let t0 = S.fsquare_times b 5 in let b = P.fmul t0 b in feval h1 as0 == a /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs)) let finv1 #s i t1 tmp =
true
null
false
let h0 = ST.get () in let a:felem s = sub t1 0ul (nlimb s) in let b:felem s = sub t1 (nlimb s) (nlimb s) in let c:felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0:felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1:felem_wide s = sub tmp 0ul (nwide s) in fsquare_times #s a i tmp1 1ul; fsquare_times #s t0 a tmp1 2ul; fmul_s #s b t0 i tmp; fmul_s #s a b a tmp; fsquare_times #s t0 a tmp1 1ul; fmul_s #s b t0 b tmp; fsquare_times #s t0 b tmp1 5ul; fmul_s #s b t0 b tmp
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Hacl.Impl.Curve25519.Fields.Core.felem", "Lib.Buffer.lbuffer", "Hacl.Impl.Curve25519.Fields.Core.limb", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Curve25519.Fields.Core.nlimb", "Hacl.Impl.Curve25519.Fields.Core.felem_wide2", "Hacl.Impl.Curve25519.Finv.fmul_s", "Prims.unit", "Hacl.Impl.Curve25519.Finv.fsquare_times", "Hacl.Impl.Curve25519.Fields.Core.felem_wide", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Hacl.Impl.Curve25519.Fields.Core.wide", "Lib.IntTypes.op_Plus_Dot", "Hacl.Impl.Curve25519.Fields.Core.nwide", "Lib.Buffer.lbuffer_t", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) [@ Meta.Attribute.inline_ ] let fsqr_s #s out f1 tmp = C.fsqr #s out f1 tmp noextract val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0 let fmuls_pre #s h f1 f2 = match s with | M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1) | M64 -> True val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2)) [@ Meta.Attribute.inline_ ] let fmul_s #s out f1 f2 tmp = C.fmul #s out f1 f2 tmp val fsquare_times: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide s -> n:size_t{v n > 0} -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ (disjoint o i \/ o == i) /\ disjoint o tmp /\ disjoint tmp i /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == S.pow (feval #s h0 i) (pow2 (v n))) [@ Meta.Attribute.specialize ] let fsquare_times #s o inp tmp n = let h0 = ST.get() in fsqr_s #s o inp tmp; S.lemma_pow_one (feval h0 inp); S.lemma_pow_add (feval h0 inp) 1 1; assert_norm (pow2 1 = 2); let inv (h:mem) (i:nat{i < v n}) = modifies (loc o |+| loc tmp) h0 h /\ fsquare_times_inv #s h o /\ feval h o == S.pow (feval #s h0 inp) (pow2 (i + 1)) in let h1 = ST.get () in assert (inv h1 0); Lib.Loops.for 0ul (n -! 1ul) inv (fun i -> let h2 = ST.get () in fsqr_s #s o o tmp; S.lemma_pow_add (feval #s h0 inp) (pow2 (v i + 1)) (pow2 (v i + 1)); Math.Lemmas.pow2_double_sum (v i + 1)) val finv1: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let a = S.fsquare_times (feval h0 i) 1 in let t0 = S.fsquare_times a 2 in let b = P.fmul t0 (feval h0 i) in let a = P.fmul b a in let t0 = S.fsquare_times a 1 in let b = P.fmul t0 b in let t0 = S.fsquare_times b 5 in let b = P.fmul t0 b in feval h1 as0 == a /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs))
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finv1: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let a = S.fsquare_times (feval h0 i) 1 in let t0 = S.fsquare_times a 2 in let b = P.fmul t0 (feval h0 i) in let a = P.fmul b a in let t0 = S.fsquare_times a 1 in let b = P.fmul t0 b in let t0 = S.fsquare_times b 5 in let b = P.fmul t0 b in feval h1 as0 == a /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs))
[]
Hacl.Impl.Curve25519.Finv.finv1
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Hacl.Impl.Curve25519.Fields.Core.felem s -> t1: Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s) (4ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s) -> tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 39, "end_line": 163, "start_col": 23, "start_line": 149 }
FStar.HyperStack.ST.Stack
val finv0: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let a_s, t0_s = S.finv0 (feval h0 i) in let a = gsub t1 0ul (nlimb s) in let t0 = gsub t1 (3ul *! nlimb s) (nlimb s) in fsquare_times_inv h1 a /\ fsquare_times_inv h1 t0 /\ (feval h1 a, feval h1 t0) == (a_s, t0_s)))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finv0 #s i t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in finv1 #s i t1 tmp; finv2 #s t1 tmp; finv3 #s t1 tmp; let h1 = ST.get () in assert (fsquare_times_inv h1 t0); assert (fsquare_times_inv h1 a); assert (modifies (loc t1 |+| loc tmp) h0 h1); assert ( (feval h1 a, feval h1 t0) == S.finv0 (feval h0 i))
val finv0: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let a_s, t0_s = S.finv0 (feval h0 i) in let a = gsub t1 0ul (nlimb s) in let t0 = gsub t1 (3ul *! nlimb s) (nlimb s) in fsquare_times_inv h1 a /\ fsquare_times_inv h1 t0 /\ (feval h1 a, feval h1 t0) == (a_s, t0_s))) let finv0 #s i t1 tmp =
true
null
false
let h0 = ST.get () in let a:felem s = sub t1 0ul (nlimb s) in let b:felem s = sub t1 (nlimb s) (nlimb s) in let c:felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0:felem s = sub t1 (3ul *! nlimb s) (nlimb s) in finv1 #s i t1 tmp; finv2 #s t1 tmp; finv3 #s t1 tmp; let h1 = ST.get () in assert (fsquare_times_inv h1 t0); assert (fsquare_times_inv h1 a); assert (modifies (loc t1 |+| loc tmp) h0 h1); assert ((feval h1 a, feval h1 t0) == S.finv0 (feval h0 i))
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Hacl.Impl.Curve25519.Fields.Core.felem", "Lib.Buffer.lbuffer", "Hacl.Impl.Curve25519.Fields.Core.limb", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Curve25519.Fields.Core.nlimb", "Hacl.Impl.Curve25519.Fields.Core.felem_wide2", "Prims._assert", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "Spec.Curve25519.elem", "FStar.Pervasives.Native.Mktuple2", "Hacl.Impl.Curve25519.Fields.Core.feval", "Hacl.Spec.Curve25519.Finv.finv0", "Prims.unit", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Lib.Buffer.MUT", "Hacl.Impl.Curve25519.Fields.Core.wide", "Hacl.Impl.Curve25519.Finv.fsquare_times_inv", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.Curve25519.Finv.finv3", "Hacl.Impl.Curve25519.Finv.finv2", "Hacl.Impl.Curve25519.Finv.finv1", "Lib.Buffer.sub", "Lib.Buffer.lbuffer_t" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) [@ Meta.Attribute.inline_ ] let fsqr_s #s out f1 tmp = C.fsqr #s out f1 tmp noextract val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0 let fmuls_pre #s h f1 f2 = match s with | M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1) | M64 -> True val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2)) [@ Meta.Attribute.inline_ ] let fmul_s #s out f1 f2 tmp = C.fmul #s out f1 f2 tmp val fsquare_times: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide s -> n:size_t{v n > 0} -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ (disjoint o i \/ o == i) /\ disjoint o tmp /\ disjoint tmp i /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == S.pow (feval #s h0 i) (pow2 (v n))) [@ Meta.Attribute.specialize ] let fsquare_times #s o inp tmp n = let h0 = ST.get() in fsqr_s #s o inp tmp; S.lemma_pow_one (feval h0 inp); S.lemma_pow_add (feval h0 inp) 1 1; assert_norm (pow2 1 = 2); let inv (h:mem) (i:nat{i < v n}) = modifies (loc o |+| loc tmp) h0 h /\ fsquare_times_inv #s h o /\ feval h o == S.pow (feval #s h0 inp) (pow2 (i + 1)) in let h1 = ST.get () in assert (inv h1 0); Lib.Loops.for 0ul (n -! 1ul) inv (fun i -> let h2 = ST.get () in fsqr_s #s o o tmp; S.lemma_pow_add (feval #s h0 inp) (pow2 (v i + 1)) (pow2 (v i + 1)); Math.Lemmas.pow2_double_sum (v i + 1)) val finv1: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let a = S.fsquare_times (feval h0 i) 1 in let t0 = S.fsquare_times a 2 in let b = P.fmul t0 (feval h0 i) in let a = P.fmul b a in let t0 = S.fsquare_times a 1 in let b = P.fmul t0 b in let t0 = S.fsquare_times b 5 in let b = P.fmul t0 b in feval h1 as0 == a /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs)) [@ Meta.Attribute.inline_ ] let finv1 #s i t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2 *) fsquare_times #s a i tmp1 1ul; (* 8 *) fsquare_times #s t0 a tmp1 2ul; (* 9 *) fmul_s #s b t0 i tmp; (* 11 *) fmul_s #s a b a tmp; (* 22 *) fsquare_times #s t0 a tmp1 1ul; (* 2^5 - 2^0 = 31 *) fmul_s #s b t0 b tmp; (* 2^10 - 2^5 *) fsquare_times #s t0 b tmp1 5ul; (* 2^10 - 2^0 *) fmul_s #s b t0 b tmp val finv2: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 bs) 10 in let c = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times c 20 in let t0 = P.fmul t0 c in let t0 = S.fsquare_times t0 10 in let b = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times b 50 in let c = P.fmul t0 b in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs /\ feval h1 cs == c /\ fsquare_times_inv h1 cs)) [@ Meta.Attribute.inline_ ] let finv2 #s t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2^20 - 2^10 *) fsquare_times #s t0 b tmp1 10ul; (* 2^20 - 2^0 *) fmul_s #s c t0 b tmp; (* 2^40 - 2^20 *) fsquare_times #s t0 c tmp1 20ul; (* 2^40 - 2^0 *) fmul_s #s t0 t0 c tmp; (* 2^50 - 2^10 *) fsquare_times #s t0 t0 tmp1 10ul; (* 2^50 - 2^0 *) fmul_s #s b t0 b tmp; (* 2^100 - 2^50 *) fsquare_times #s t0 b tmp1 50ul; (* 2^100 - 2^0 *) fmul_s #s c t0 b tmp val finv3: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs /\ fsquare_times_inv h0 cs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let ts0 : felem s = gsub t1 (3ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 cs) 100 in let t0 = P.fmul t0 (feval h0 cs) in let t0 = S.fsquare_times t0 50 in let t0 = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times t0 5 in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 ts0 == t0 /\ fsquare_times_inv h1 ts0)) [@ Meta.Attribute.inline_ ] let finv3 #s t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2^200 - 2^100 *) fsquare_times #s t0 c tmp1 100ul; (* 2^200 - 2^0 *) fmul_s #s t0 t0 c tmp; (* 2^250 - 2^50 *) fsquare_times #s t0 t0 tmp1 50ul; (* 2^250 - 2^0 *) fmul_s #s t0 t0 b tmp; (* 2^255 - 2^5 *) fsquare_times #s t0 t0 tmp1 5ul val finv0: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let a_s, t0_s = S.finv0 (feval h0 i) in let a = gsub t1 0ul (nlimb s) in let t0 = gsub t1 (3ul *! nlimb s) (nlimb s) in fsquare_times_inv h1 a /\ fsquare_times_inv h1 t0 /\ (feval h1 a, feval h1 t0) == (a_s, t0_s)))
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finv0: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let a_s, t0_s = S.finv0 (feval h0 i) in let a = gsub t1 0ul (nlimb s) in let t0 = gsub t1 (3ul *! nlimb s) (nlimb s) in fsquare_times_inv h1 a /\ fsquare_times_inv h1 t0 /\ (feval h1 a, feval h1 t0) == (a_s, t0_s)))
[]
Hacl.Impl.Curve25519.Finv.finv0
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Hacl.Impl.Curve25519.Fields.Core.felem s -> t1: Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s) (4ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s) -> tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 61, "end_line": 285, "start_col": 23, "start_line": 272 }
FStar.HyperStack.ST.Stack
val finv2: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 bs) 10 in let c = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times c 20 in let t0 = P.fmul t0 c in let t0 = S.fsquare_times t0 10 in let b = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times b 50 in let c = P.fmul t0 b in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs /\ feval h1 cs == c /\ fsquare_times_inv h1 cs))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finv2 #s t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2^20 - 2^10 *) fsquare_times #s t0 b tmp1 10ul; (* 2^20 - 2^0 *) fmul_s #s c t0 b tmp; (* 2^40 - 2^20 *) fsquare_times #s t0 c tmp1 20ul; (* 2^40 - 2^0 *) fmul_s #s t0 t0 c tmp; (* 2^50 - 2^10 *) fsquare_times #s t0 t0 tmp1 10ul; (* 2^50 - 2^0 *) fmul_s #s b t0 b tmp; (* 2^100 - 2^50 *) fsquare_times #s t0 b tmp1 50ul; (* 2^100 - 2^0 *) fmul_s #s c t0 b tmp
val finv2: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 bs) 10 in let c = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times c 20 in let t0 = P.fmul t0 c in let t0 = S.fsquare_times t0 10 in let b = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times b 50 in let c = P.fmul t0 b in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs /\ feval h1 cs == c /\ fsquare_times_inv h1 cs)) let finv2 #s t1 tmp =
true
null
false
let h0 = ST.get () in let a:felem s = sub t1 0ul (nlimb s) in let b:felem s = sub t1 (nlimb s) (nlimb s) in let c:felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0:felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1:felem_wide s = sub tmp 0ul (nwide s) in fsquare_times #s t0 b tmp1 10ul; fmul_s #s c t0 b tmp; fsquare_times #s t0 c tmp1 20ul; fmul_s #s t0 t0 c tmp; fsquare_times #s t0 t0 tmp1 10ul; fmul_s #s b t0 b tmp; fsquare_times #s t0 b tmp1 50ul; fmul_s #s c t0 b tmp
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Lib.Buffer.lbuffer", "Hacl.Impl.Curve25519.Fields.Core.limb", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Curve25519.Fields.Core.nlimb", "Hacl.Impl.Curve25519.Fields.Core.felem_wide2", "Hacl.Impl.Curve25519.Finv.fmul_s", "Prims.unit", "Hacl.Impl.Curve25519.Finv.fsquare_times", "Hacl.Impl.Curve25519.Fields.Core.felem_wide", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Hacl.Impl.Curve25519.Fields.Core.wide", "Lib.IntTypes.op_Plus_Dot", "Hacl.Impl.Curve25519.Fields.Core.nwide", "Lib.Buffer.lbuffer_t", "Hacl.Impl.Curve25519.Fields.Core.felem", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) [@ Meta.Attribute.inline_ ] let fsqr_s #s out f1 tmp = C.fsqr #s out f1 tmp noextract val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0 let fmuls_pre #s h f1 f2 = match s with | M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1) | M64 -> True val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2)) [@ Meta.Attribute.inline_ ] let fmul_s #s out f1 f2 tmp = C.fmul #s out f1 f2 tmp val fsquare_times: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide s -> n:size_t{v n > 0} -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ (disjoint o i \/ o == i) /\ disjoint o tmp /\ disjoint tmp i /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == S.pow (feval #s h0 i) (pow2 (v n))) [@ Meta.Attribute.specialize ] let fsquare_times #s o inp tmp n = let h0 = ST.get() in fsqr_s #s o inp tmp; S.lemma_pow_one (feval h0 inp); S.lemma_pow_add (feval h0 inp) 1 1; assert_norm (pow2 1 = 2); let inv (h:mem) (i:nat{i < v n}) = modifies (loc o |+| loc tmp) h0 h /\ fsquare_times_inv #s h o /\ feval h o == S.pow (feval #s h0 inp) (pow2 (i + 1)) in let h1 = ST.get () in assert (inv h1 0); Lib.Loops.for 0ul (n -! 1ul) inv (fun i -> let h2 = ST.get () in fsqr_s #s o o tmp; S.lemma_pow_add (feval #s h0 inp) (pow2 (v i + 1)) (pow2 (v i + 1)); Math.Lemmas.pow2_double_sum (v i + 1)) val finv1: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let a = S.fsquare_times (feval h0 i) 1 in let t0 = S.fsquare_times a 2 in let b = P.fmul t0 (feval h0 i) in let a = P.fmul b a in let t0 = S.fsquare_times a 1 in let b = P.fmul t0 b in let t0 = S.fsquare_times b 5 in let b = P.fmul t0 b in feval h1 as0 == a /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs)) [@ Meta.Attribute.inline_ ] let finv1 #s i t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2 *) fsquare_times #s a i tmp1 1ul; (* 8 *) fsquare_times #s t0 a tmp1 2ul; (* 9 *) fmul_s #s b t0 i tmp; (* 11 *) fmul_s #s a b a tmp; (* 22 *) fsquare_times #s t0 a tmp1 1ul; (* 2^5 - 2^0 = 31 *) fmul_s #s b t0 b tmp; (* 2^10 - 2^5 *) fsquare_times #s t0 b tmp1 5ul; (* 2^10 - 2^0 *) fmul_s #s b t0 b tmp val finv2: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 bs) 10 in let c = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times c 20 in let t0 = P.fmul t0 c in let t0 = S.fsquare_times t0 10 in let b = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times b 50 in let c = P.fmul t0 b in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs /\ feval h1 cs == c /\ fsquare_times_inv h1 cs))
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finv2: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 bs) 10 in let c = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times c 20 in let t0 = P.fmul t0 c in let t0 = S.fsquare_times t0 10 in let b = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times b 50 in let c = P.fmul t0 b in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs /\ feval h1 cs == c /\ fsquare_times_inv h1 cs))
[]
Hacl.Impl.Curve25519.Finv.finv2
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t1: Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s) (4ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s) -> tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 40, "end_line": 208, "start_col": 21, "start_line": 194 }
FStar.HyperStack.ST.Stack
val finv: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ disjoint o i /\ disjoint i tmp /\ (disjoint o tmp) /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == P.fpow (feval #s h0 i) (pow2 255 - 21))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finv #s o i tmp = push_frame(); let t1 = create (4ul *! nlimb s) (limb_zero s) in let h0 = ST.get () in finv0 #s i t1 tmp; let a : felem s = sub t1 0ul (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in (* 2^255 - 21 *) fmul_s #s o t0 a tmp; let h1 = ST.get () in assert (feval h1 o == S.finv (feval h0 i)); pop_frame()
val finv: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ disjoint o i /\ disjoint i tmp /\ (disjoint o tmp) /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == P.fpow (feval #s h0 i) (pow2 255 - 21)) let finv #s o i tmp =
true
null
false
push_frame (); let t1 = create (4ul *! nlimb s) (limb_zero s) in let h0 = ST.get () in finv0 #s i t1 tmp; let a:felem s = sub t1 0ul (nlimb s) in let t0:felem s = sub t1 (3ul *! nlimb s) (nlimb s) in fmul_s #s o t0 a tmp; let h1 = ST.get () in assert (feval h1 o == S.finv (feval h0 i)); pop_frame ()
{ "checked_file": "Hacl.Impl.Curve25519.Finv.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Loops.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Finv.fst" }
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Hacl.Impl.Curve25519.Fields.Core.felem", "Hacl.Impl.Curve25519.Fields.Core.felem_wide2", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Prims._assert", "Prims.eq2", "Spec.Curve25519.elem", "Hacl.Impl.Curve25519.Fields.Core.feval", "Hacl.Spec.Curve25519.Finv.finv", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.Curve25519.Finv.fmul_s", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Hacl.Impl.Curve25519.Fields.Core.limb", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Curve25519.Fields.Core.nlimb", "Lib.Buffer.lbuffer_t", "Hacl.Impl.Curve25519.Finv.finv0", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Hacl.Impl.Curve25519.Fields.Core.limb_zero", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Curve25519.Finv open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module C = Hacl.Impl.Curve25519.Fields.Core module S = Hacl.Spec.Curve25519.Finv module P = Spec.Curve25519 let _: squash (inversion field_spec) = allow_inversion field_spec #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0 --record_options" noextract val fsquare_times_inv: #s:field_spec -> h:mem -> f:felem s -> Type0 let fsquare_times_inv #s h f = match s with | M51 -> C.f51_felem_fits h f (1, 2, 1, 1, 1) | M64 -> True val fsqr_s: #s:field_spec -> out:felem s -> f1:felem s -> tmp:felem_wide s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out tmp) /\ disjoint tmp f1 /\ fsquare_times_inv h f1) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f1)) [@ Meta.Attribute.inline_ ] let fsqr_s #s out f1 tmp = C.fsqr #s out f1 tmp noextract val fmuls_pre: #s:field_spec -> h:mem -> f1:felem s -> f2:felem s -> Type0 let fmuls_pre #s h f1 f2 = match s with | M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1) | M64 -> True val fmul_s: #s:field_spec -> out:felem s -> f1:felem s -> f2:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ (disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\ (disjoint out tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\ disjoint f2 tmp /\ fmuls_pre h f1 f2) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 out /\ feval h1 out == P.fmul (feval h0 f1) (feval h0 f2)) [@ Meta.Attribute.inline_ ] let fmul_s #s out f1 f2 tmp = C.fmul #s out f1 f2 tmp val fsquare_times: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide s -> n:size_t{v n > 0} -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ (disjoint o i \/ o == i) /\ disjoint o tmp /\ disjoint tmp i /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == S.pow (feval #s h0 i) (pow2 (v n))) [@ Meta.Attribute.specialize ] let fsquare_times #s o inp tmp n = let h0 = ST.get() in fsqr_s #s o inp tmp; S.lemma_pow_one (feval h0 inp); S.lemma_pow_add (feval h0 inp) 1 1; assert_norm (pow2 1 = 2); let inv (h:mem) (i:nat{i < v n}) = modifies (loc o |+| loc tmp) h0 h /\ fsquare_times_inv #s h o /\ feval h o == S.pow (feval #s h0 inp) (pow2 (i + 1)) in let h1 = ST.get () in assert (inv h1 0); Lib.Loops.for 0ul (n -! 1ul) inv (fun i -> let h2 = ST.get () in fsqr_s #s o o tmp; S.lemma_pow_add (feval #s h0 inp) (pow2 (v i + 1)) (pow2 (v i + 1)); Math.Lemmas.pow2_double_sum (v i + 1)) val finv1: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let a = S.fsquare_times (feval h0 i) 1 in let t0 = S.fsquare_times a 2 in let b = P.fmul t0 (feval h0 i) in let a = P.fmul b a in let t0 = S.fsquare_times a 1 in let b = P.fmul t0 b in let t0 = S.fsquare_times b 5 in let b = P.fmul t0 b in feval h1 as0 == a /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs)) [@ Meta.Attribute.inline_ ] let finv1 #s i t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2 *) fsquare_times #s a i tmp1 1ul; (* 8 *) fsquare_times #s t0 a tmp1 2ul; (* 9 *) fmul_s #s b t0 i tmp; (* 11 *) fmul_s #s a b a tmp; (* 22 *) fsquare_times #s t0 a tmp1 1ul; (* 2^5 - 2^0 = 31 *) fmul_s #s b t0 b tmp; (* 2^10 - 2^5 *) fsquare_times #s t0 b tmp1 5ul; (* 2^10 - 2^0 *) fmul_s #s b t0 b tmp val finv2: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 bs) 10 in let c = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times c 20 in let t0 = P.fmul t0 c in let t0 = S.fsquare_times t0 10 in let b = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times b 50 in let c = P.fmul t0 b in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 bs == b /\ fsquare_times_inv h1 bs /\ feval h1 cs == c /\ fsquare_times_inv h1 cs)) [@ Meta.Attribute.inline_ ] let finv2 #s t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2^20 - 2^10 *) fsquare_times #s t0 b tmp1 10ul; (* 2^20 - 2^0 *) fmul_s #s c t0 b tmp; (* 2^40 - 2^20 *) fsquare_times #s t0 c tmp1 20ul; (* 2^40 - 2^0 *) fmul_s #s t0 t0 c tmp; (* 2^50 - 2^10 *) fsquare_times #s t0 t0 tmp1 10ul; (* 2^50 - 2^0 *) fmul_s #s b t0 b tmp; (* 2^100 - 2^50 *) fsquare_times #s t0 b tmp1 50ul; (* 2^100 - 2^0 *) fmul_s #s c t0 b tmp val finv3: #s:field_spec -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 t1 /\ live h0 tmp /\ disjoint t1 tmp /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in fsquare_times_inv h0 as0 /\ fsquare_times_inv h0 bs /\ fsquare_times_inv h0 cs)) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let as0 : felem s = gsub t1 0ul (nlimb s) in let bs : felem s = gsub t1 (nlimb s) (nlimb s) in let cs : felem s = gsub t1 (2ul *! nlimb s) (nlimb s) in let ts0 : felem s = gsub t1 (3ul *! nlimb s) (nlimb s) in let t0 = S.fsquare_times (feval h0 cs) 100 in let t0 = P.fmul t0 (feval h0 cs) in let t0 = S.fsquare_times t0 50 in let t0 = P.fmul t0 (feval h0 bs) in let t0 = S.fsquare_times t0 5 in feval h1 as0 == feval h0 as0 /\ fsquare_times_inv h1 as0 /\ feval h1 ts0 == t0 /\ fsquare_times_inv h1 ts0)) [@ Meta.Attribute.inline_ ] let finv3 #s t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in let tmp1 : felem_wide s = sub tmp 0ul (nwide s) in (* 2^200 - 2^100 *) fsquare_times #s t0 c tmp1 100ul; (* 2^200 - 2^0 *) fmul_s #s t0 t0 c tmp; (* 2^250 - 2^50 *) fsquare_times #s t0 t0 tmp1 50ul; (* 2^250 - 2^0 *) fmul_s #s t0 t0 b tmp; (* 2^255 - 2^5 *) fsquare_times #s t0 t0 tmp1 5ul val finv0: #s:field_spec -> i:felem s -> t1:lbuffer (limb s) (4ul *! nlimb s) -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 i /\ live h0 t1 /\ live h0 tmp /\ disjoint i t1 /\ disjoint i tmp /\ disjoint t1 tmp /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc t1 |+| loc tmp) h0 h1 /\ (let a_s, t0_s = S.finv0 (feval h0 i) in let a = gsub t1 0ul (nlimb s) in let t0 = gsub t1 (3ul *! nlimb s) (nlimb s) in fsquare_times_inv h1 a /\ fsquare_times_inv h1 t0 /\ (feval h1 a, feval h1 t0) == (a_s, t0_s))) [@ Meta.Attribute.inline_ ] let finv0 #s i t1 tmp = let h0 = ST.get () in let a : felem s = sub t1 0ul (nlimb s) in let b : felem s = sub t1 (nlimb s) (nlimb s) in let c : felem s = sub t1 (2ul *! nlimb s) (nlimb s) in let t0 : felem s = sub t1 (3ul *! nlimb s) (nlimb s) in finv1 #s i t1 tmp; finv2 #s t1 tmp; finv3 #s t1 tmp; let h1 = ST.get () in assert (fsquare_times_inv h1 t0); assert (fsquare_times_inv h1 a); assert (modifies (loc t1 |+| loc tmp) h0 h1); assert ( (feval h1 a, feval h1 t0) == S.finv0 (feval h0 i)) val finv: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ disjoint o i /\ disjoint i tmp /\ (disjoint o tmp) /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == P.fpow (feval #s h0 i) (pow2 255 - 21)) [@ Meta.Attribute.specialize ]
false
false
Hacl.Impl.Curve25519.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finv: #s:field_spec -> o:felem s -> i:felem s -> tmp:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 o /\ live h0 i /\ live h0 tmp /\ disjoint o i /\ disjoint i tmp /\ (disjoint o tmp) /\ fsquare_times_inv h0 i) (ensures fun h0 _ h1 -> modifies (loc o |+| loc tmp) h0 h1 /\ fsquare_times_inv h1 o /\ feval h1 o == P.fpow (feval #s h0 i) (pow2 255 - 21))
[]
Hacl.Impl.Curve25519.Finv.finv
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Hacl.Impl.Curve25519.Fields.Core.felem s -> i: Hacl.Impl.Curve25519.Fields.Core.felem s -> tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 314, "start_col": 2, "start_line": 305 }
Prims.Tot
val exp_mont_ladder (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0
val exp_mont_ladder (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t let exp_mont_ladder (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t =
false
null
false
let r0, r1 = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Lib.LoopCombinators.repeati", "Lib.Exponentiation.exp_mont_ladder_f", "FStar.Pervasives.Native.Mktuple2", "Lib.Exponentiation.Definition.one" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1)
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_mont_ladder (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[]
Lib.Exponentiation.exp_mont_ladder
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> t
{ "end_col": 4, "end_line": 49, "start_col": 95, "start_line": 47 }
Prims.Tot
val exp_lr (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one
val exp_lr (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t let exp_lr (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t =
false
null
false
Loops.repeati bBits (exp_lr_f k a bBits b) one
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Lib.LoopCombinators.repeati", "Lib.Exponentiation.exp_lr_f", "Lib.Exponentiation.Definition.one" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_lr (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[]
Lib.Exponentiation.exp_lr
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> t
{ "end_col": 48, "end_line": 34, "start_col": 2, "start_line": 34 }
Prims.Tot
val exp_mont_ladder_swap2 (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0
val exp_mont_ladder_swap2 (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t let exp_mont_ladder_swap2 (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t =
false
null
false
let r0, r1 = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Lib.LoopCombinators.repeati", "Lib.Exponentiation.exp_mont_ladder_swap2_f", "FStar.Pervasives.Native.Mktuple2", "Lib.Exponentiation.Definition.one" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1)
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_mont_ladder_swap2 (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[]
Lib.Exponentiation.exp_mont_ladder_swap2
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> t
{ "end_col": 4, "end_line": 69, "start_col": 101, "start_line": 67 }
Prims.Tot
val exp_mont_ladder_swap (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0
val exp_mont_ladder_swap (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t let exp_mont_ladder_swap (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t =
false
null
false
let r0, r1, sw = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let r0, r1 = cswap sw r0 r1 in r0
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Lib.Exponentiation.cswap", "FStar.Pervasives.Native.tuple3", "Lib.LoopCombinators.repeati", "Lib.Exponentiation.exp_mont_ladder_swap_f", "FStar.Pervasives.Native.Mktuple3", "Lib.Exponentiation.Definition.one" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit)
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_mont_ladder_swap (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[]
Lib.Exponentiation.exp_mont_ladder_swap
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> t
{ "end_col": 4, "end_line": 86, "start_col": 100, "start_line": 83 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c)
let exp_rl_f (#t: Type) (k: comm_monoid t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (acc, c: tuple2 t t) : tuple2 t t =
false
null
false
let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c)
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Lib.Exponentiation.Definition.mul", "Prims.op_Equality", "Prims.int", "Lib.Exponentiation.get_ith_bit", "Prims.bool" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_rl_f : k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: (t * t) -> t * t
[]
Lib.Exponentiation.exp_rl_f
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: (t * t) -> t * t
{ "end_col": 10, "end_line": 17, "start_col": 134, "start_line": 14 }
Prims.Tot
val exp_rl (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[ { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc
val exp_rl (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t let exp_rl (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t =
false
null
false
let acc, c = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Lib.LoopCombinators.repeati", "Lib.Exponentiation.exp_rl_f", "FStar.Pervasives.Native.Mktuple2", "Lib.Exponentiation.Definition.one" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c)
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_rl (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[]
Lib.Exponentiation.exp_rl
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> t
{ "end_col": 5, "end_line": 21, "start_col": 86, "start_line": 19 }
Prims.Tot
val cswap (#t: Type) (sw: nat) (r0 r1: t) : tuple2 t t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1)
val cswap (#t: Type) (sw: nat) (r0 r1: t) : tuple2 t t let cswap (#t: Type) (sw: nat) (r0 r1: t) : tuple2 t t =
false
null
false
if sw = 1 then (r1, r0) else (r0, r1)
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "FStar.Pervasives.Native.tuple2" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap (#t: Type) (sw: nat) (r0 r1: t) : tuple2 t t
[]
Lib.Exponentiation.cswap
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
sw: Prims.nat -> r0: t -> r1: t -> t * t
{ "end_col": 39, "end_line": 57, "start_col": 2, "start_line": 57 }
Prims.Tot
val exp_pow2 (#t: Type) (k: comm_monoid t) (a: t) (b: nat) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a
val exp_pow2 (#t: Type) (k: comm_monoid t) (a: t) (b: nat) : t let exp_pow2 (#t: Type) (k: comm_monoid t) (a: t) (b: nat) : t =
false
null
false
Loops.repeat b (sqr k) a
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Lib.LoopCombinators.repeat", "Lib.Exponentiation.Definition.sqr" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_pow2 (#t: Type) (k: comm_monoid t) (a: t) (b: nat) : t
[]
Lib.Exponentiation.exp_pow2
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> b: Prims.nat -> t
{ "end_col": 26, "end_line": 94, "start_col": 2, "start_line": 94 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2
let get_ith_bit (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) =
false
null
false
b / pow2 i % 2
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.op_Modulus", "Prims.op_Division", "Prims.int" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_ith_bit : bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> Prims.int
[]
Lib.Exponentiation.get_ith_bit
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> Prims.int
{ "end_col": 16, "end_line": 11, "start_col": 2, "start_line": 11 }
Prims.Tot
val exp_lr_f (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (acc: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc
val exp_lr_f (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (acc: t) : t let exp_lr_f (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (acc: t) : t =
false
null
false
let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.op_Equality", "Prims.int", "Lib.Exponentiation.get_ith_bit", "Prims.op_Subtraction", "Prims.bool", "Lib.Exponentiation.Definition.mul" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b)
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_lr_f (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (acc: t) : t
[]
Lib.Exponentiation.exp_lr_f
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> acc: t -> t
{ "end_col": 5, "end_line": 31, "start_col": 115, "start_line": 28 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1)
let exp_mont_ladder_f (#t: Type) (k: comm_monoid t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (r0, r1: tuple2 t t) : tuple2 t t =
false
null
false
if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1)
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Prims.op_Equality", "Prims.int", "Lib.Exponentiation.get_ith_bit", "Prims.op_Subtraction", "FStar.Pervasives.Native.Mktuple2", "Lib.Exponentiation.Definition.mul", "Prims.bool" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_mont_ladder_f : k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: (t * t) -> t * t
[]
Lib.Exponentiation.exp_mont_ladder_f
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: (t * t) -> t * t
{ "end_col": 26, "end_line": 45, "start_col": 2, "start_line": 42 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l
let get_ith_lbits (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (l: pos) =
false
null
false
b / pow2 i % pow2 l
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Modulus", "Prims.op_Division", "Prims.int" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b))
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_ith_lbits : bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> l: Prims.pos -> Prims.int
[]
Lib.Exponentiation.get_ith_lbits
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> l: Prims.pos -> Prims.int
{ "end_col": 21, "end_line": 101, "start_col": 2, "start_line": 101 }
Prims.Tot
val mul_acc_pow_a_bits_l (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l)
val mul_acc_pow_a_bits_l (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t let mul_acc_pow_a_bits_l (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t =
false
null
false
let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l)
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Division", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.get_bits_l" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_acc_pow_a_bits_l (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[]
Lib.Exponentiation.mul_acc_pow_a_bits_l
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i < bBits / l} -> acc: t -> t
{ "end_col": 26, "end_line": 110, "start_col": 139, "start_line": 108 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1)
let exp_mont_ladder_swap2_f (#t: Type) (k: comm_monoid t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (r0, r1: tuple2 t t) : tuple2 t t =
false
null
false
let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1)
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Lib.Exponentiation.cswap", "Lib.Exponentiation.Definition.mul", "Prims.int", "Lib.Exponentiation.get_ith_bit", "Prims.op_Subtraction" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1)
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_mont_ladder_swap2_f : k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: (t * t) -> t * t
[]
Lib.Exponentiation.exp_mont_ladder_swap2_f
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: (t * t) -> t * t
{ "end_col": 10, "end_line": 65, "start_col": 149, "start_line": 60 }
Prims.Tot
val exp_double_fw_f (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_double_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1
val exp_double_fw_f (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t let exp_double_fw_f (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t =
false
null
false
let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Division", "Lib.Exponentiation.mul_acc_pow_a_bits_l", "Lib.Exponentiation.exp_fw_f" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1 let exp_fw_acc0 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let exp_fw (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in res val exp_fw_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (exp_fw k a bBits b l == pow k a b) /// Multi-Exponentiation // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- let exp_double_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits})
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_double_fw_f (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[]
Lib.Exponentiation.exp_double_fw_f
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i < bBits / l} -> acc: t -> t
{ "end_col": 45, "end_line": 141, "start_col": 2, "start_line": 139 }
Prims.Tot
val exp_fw (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_fw (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in res
val exp_fw (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) : t let exp_fw (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) : t =
false
null
false
let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in res
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Lib.LoopCombinators.repeati", "Prims.op_Division", "Lib.Exponentiation.exp_fw_f", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Lib.Exponentiation.Definition.one", "Prims.bool", "Lib.Exponentiation.exp_fw_acc0" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1 let exp_fw_acc0 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_fw (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) : t
[]
Lib.Exponentiation.exp_fw
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos -> t
{ "end_col": 5, "end_line": 124, "start_col": 94, "start_line": 121 }
Prims.Tot
val exp_double_fw_acc0 (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos{bBits % l <> 0}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_double_fw_acc0 (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in mul acc_a1 acc_a2
val exp_double_fw_acc0 (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos{bBits % l <> 0}) : t let exp_double_fw_acc0 (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos{bBits % l <> 0}) : t =
false
null
false
let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in mul acc_a1 acc_a2
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_disEquality", "Prims.int", "Prims.op_Modulus", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.exp_fw_acc0" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1 let exp_fw_acc0 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let exp_fw (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in res val exp_fw_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (exp_fw k a bBits b l == pow k a b) /// Multi-Exponentiation // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- let exp_double_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1 let exp_double_fw_acc0 (#t:Type) (k:comm_monoid t)
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_double_fw_acc0 (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos{bBits % l <> 0}) : t
[]
Lib.Exponentiation.exp_double_fw_acc0
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> l: Prims.pos{bBits % l <> 0} -> t
{ "end_col": 19, "end_line": 148, "start_col": 64, "start_line": 145 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit)
let exp_mont_ladder_swap_f (#t: Type) (k: comm_monoid t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (r0, r1, privbit: tuple3 t t nat) : tuple3 t t nat =
false
null
false
let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit)
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.Mktuple3", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.cswap", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "Lib.Exponentiation.get_ith_bit", "Prims.op_Subtraction" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b)
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_mont_ladder_swap_f : k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: ((t * t) * Prims.nat) -> (t * t) * Prims.nat
[]
Lib.Exponentiation.exp_mont_ladder_swap_f
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: ((t * t) * Prims.nat) -> (t * t) * Prims.nat
{ "end_col": 15, "end_line": 81, "start_col": 165, "start_line": 76 }
Prims.Tot
val exp_fw_f (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_fw_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1
val exp_fw_f (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t let exp_fw_f (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t =
false
null
false
let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Division", "Lib.Exponentiation.mul_acc_pow_a_bits_l", "Lib.Exponentiation.exp_pow2" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l)
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_fw_f (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[]
Lib.Exponentiation.exp_fw_f
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i < bBits / l} -> acc: t -> t
{ "end_col": 43, "end_line": 114, "start_col": 127, "start_line": 112 }
Prims.Tot
val exp_double_fw (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_double_fw (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in Loops.repeati (bBits / l) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0
val exp_double_fw (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) : t let exp_double_fw (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) : t =
false
null
false
let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in Loops.repeati (bBits / l) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Lib.LoopCombinators.repeati", "Prims.op_Division", "Lib.Exponentiation.exp_double_fw_f", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Lib.Exponentiation.Definition.one", "Prims.bool", "Lib.Exponentiation.exp_double_fw_acc0" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1 let exp_fw_acc0 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let exp_fw (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in res val exp_fw_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (exp_fw k a bBits b l == pow k a b) /// Multi-Exponentiation // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- let exp_double_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1 let exp_double_fw_acc0 (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in mul acc_a1 acc_a2 #push-options "--z3rlimit 20" let exp_double_fw (#t:Type) (k:comm_monoid t)
false
false
Lib.Exponentiation.fsti
{ "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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_double_fw (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) : t
[]
Lib.Exponentiation.exp_double_fw
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> l: Prims.pos -> t
{ "end_col": 72, "end_line": 155, "start_col": 48, "start_line": 153 }
Prims.Tot
val exp_four_fw (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_four_fw (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_four_fw_acc0 k a1 bBits b1 a2 b2 a3 b3 a4 b4 l in Loops.repeati (bBits / l) (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0
val exp_four_fw (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) : t let exp_four_fw (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) : t =
false
null
false
let acc0 = if bBits % l = 0 then one else exp_four_fw_acc0 k a1 bBits b1 a2 b2 a3 b3 a4 b4 l in Loops.repeati (bBits / l) (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Lib.LoopCombinators.repeati", "Prims.op_Division", "Lib.Exponentiation.exp_four_fw_f", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Lib.Exponentiation.Definition.one", "Prims.bool", "Lib.Exponentiation.exp_four_fw_acc0" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1 let exp_fw_acc0 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let exp_fw (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in res val exp_fw_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (exp_fw k a bBits b l == pow k a b) /// Multi-Exponentiation // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- let exp_double_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1 let exp_double_fw_acc0 (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in mul acc_a1 acc_a2 #push-options "--z3rlimit 20" let exp_double_fw (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in Loops.repeati (bBits / l) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 #pop-options val exp_double_fw_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (exp_double_fw k a1 bBits b1 a2 b2 l == mul (pow k a1 b1) (pow k a2 b2)) // [a1^b1 `mul` a2^b2 `mul` a3^b3 `mul` a4^b4] //---------------------------------------------- let exp_four_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc = exp_fw_f k a4 bBits b4 l i acc in let acc = mul_acc_pow_a_bits_l k a3 bBits b3 l i acc in let acc = mul_acc_pow_a_bits_l k a2 bBits b2 l i acc in let acc = mul_acc_pow_a_bits_l k a1 bBits b1 l i acc in acc let exp_four_fw_acc0 (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a12 = exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in let acc_a34 = exp_double_fw_acc0 k a3 bBits b3 a4 b4 l in mul acc_a12 acc_a34 let exp_four_fw (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits})
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_four_fw (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) : t
[]
Lib.Exponentiation.exp_four_fw
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> a3: t -> b3: Prims.nat{b3 < Prims.pow2 bBits} -> a4: t -> b4: Prims.nat{b4 < Prims.pow2 bBits} -> l: Prims.pos -> t
{ "end_col": 58, "end_line": 200, "start_col": 15, "start_line": 195 }
Prims.Tot
val exp_four_fw_acc0 (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos{bBits % l <> 0}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_four_fw_acc0 (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a12 = exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in let acc_a34 = exp_double_fw_acc0 k a3 bBits b3 a4 b4 l in mul acc_a12 acc_a34
val exp_four_fw_acc0 (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos{bBits % l <> 0}) : t let exp_four_fw_acc0 (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos{bBits % l <> 0}) : t =
false
null
false
let acc_a12 = exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in let acc_a34 = exp_double_fw_acc0 k a3 bBits b3 a4 b4 l in mul acc_a12 acc_a34
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_disEquality", "Prims.int", "Prims.op_Modulus", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.exp_double_fw_acc0" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1 let exp_fw_acc0 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let exp_fw (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in res val exp_fw_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (exp_fw k a bBits b l == pow k a b) /// Multi-Exponentiation // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- let exp_double_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1 let exp_double_fw_acc0 (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in mul acc_a1 acc_a2 #push-options "--z3rlimit 20" let exp_double_fw (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in Loops.repeati (bBits / l) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 #pop-options val exp_double_fw_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (exp_double_fw k a1 bBits b1 a2 b2 l == mul (pow k a1 b1) (pow k a2 b2)) // [a1^b1 `mul` a2^b2 `mul` a3^b3 `mul` a4^b4] //---------------------------------------------- let exp_four_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc = exp_fw_f k a4 bBits b4 l i acc in let acc = mul_acc_pow_a_bits_l k a3 bBits b3 l i acc in let acc = mul_acc_pow_a_bits_l k a2 bBits b2 l i acc in let acc = mul_acc_pow_a_bits_l k a1 bBits b1 l i acc in acc let exp_four_fw_acc0 (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits})
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_four_fw_acc0 (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos{bBits % l <> 0}) : t
[]
Lib.Exponentiation.exp_four_fw_acc0
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> a3: t -> b3: Prims.nat{b3 < Prims.pow2 bBits} -> a4: t -> b4: Prims.nat{b4 < Prims.pow2 bBits} -> l: Prims.pos{bBits % l <> 0} -> t
{ "end_col": 21, "end_line": 188, "start_col": 31, "start_line": 185 }
Prims.Tot
val exp_four_fw_f (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_four_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc = exp_fw_f k a4 bBits b4 l i acc in let acc = mul_acc_pow_a_bits_l k a3 bBits b3 l i acc in let acc = mul_acc_pow_a_bits_l k a2 bBits b2 l i acc in let acc = mul_acc_pow_a_bits_l k a1 bBits b1 l i acc in acc
val exp_four_fw_f (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t let exp_four_fw_f (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t =
false
null
false
let acc = exp_fw_f k a4 bBits b4 l i acc in let acc = mul_acc_pow_a_bits_l k a3 bBits b3 l i acc in let acc = mul_acc_pow_a_bits_l k a2 bBits b2 l i acc in let acc = mul_acc_pow_a_bits_l k a1 bBits b1 l i acc in acc
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Division", "Lib.Exponentiation.mul_acc_pow_a_bits_l", "Lib.Exponentiation.exp_fw_f" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1 let exp_fw_acc0 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let exp_fw (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in res val exp_fw_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (exp_fw k a bBits b l == pow k a b) /// Multi-Exponentiation // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- let exp_double_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1 let exp_double_fw_acc0 (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in mul acc_a1 acc_a2 #push-options "--z3rlimit 20" let exp_double_fw (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in Loops.repeati (bBits / l) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 #pop-options val exp_double_fw_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (exp_double_fw k a1 bBits b1 a2 b2 l == mul (pow k a1 b1) (pow k a2 b2)) // [a1^b1 `mul` a2^b2 `mul` a3^b3 `mul` a4^b4] //---------------------------------------------- let exp_four_fw_f (#t:Type) (k:comm_monoid t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits})
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_four_fw_f (#t: Type) (k: comm_monoid t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[]
Lib.Exponentiation.exp_four_fw_f
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> a3: t -> b3: Prims.nat{b3 < Prims.pow2 bBits} -> a4: t -> b4: Prims.nat{b4 < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i < bBits / l} -> acc: t -> t
{ "end_col": 5, "end_line": 178, "start_col": 2, "start_line": 173 }
Prims.Tot
val exp_fw_acc0 (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos{bBits % l <> 0}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_fw_acc0 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c
val exp_fw_acc0 (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos{bBits % l <> 0}) : t let exp_fw_acc0 (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos{bBits % l <> 0}) : t =
false
null
false
let bits_c = get_ith_lbits bBits b ((bBits / l) * l) l in pow k a bits_c
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_disEquality", "Prims.int", "Prims.op_Modulus", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.get_ith_lbits", "FStar.Mul.op_Star", "Prims.op_Division" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l let mul_acc_pow_a_bits_l (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = get_bits_l bBits b l i in mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_fw_acc0 (#t: Type) (k: comm_monoid t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos{bBits % l <> 0}) : t
[]
Lib.Exponentiation.exp_fw_acc0
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos{bBits % l <> 0} -> t
{ "end_col": 16, "end_line": 119, "start_col": 115, "start_line": 117 }
Prims.Tot
val get_bits_l (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) : r: nat{r < pow2 l}
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bits_l (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) : r:nat{r < pow2 l} = Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l
val get_bits_l (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) : r: nat{r < pow2 l} let get_bits_l (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) : r: nat{r < pow2 l} =
false
null
false
Math.Lemmas.lemma_mult_le_left l (i + 1) (bBits / l); assert (l * (i + 1) <= l * (bBits / l)); get_ith_lbits bBits b (bBits - bBits % l - l * i - l) l
{ "checked_file": "Lib.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Division", "Lib.Exponentiation.get_ith_lbits", "Prims.op_Subtraction", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.unit", "Prims._assert", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.Math.Lemmas.lemma_mult_le_left" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators include Lib.Exponentiation.Definition #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let get_ith_bit (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) = b / pow2 i % 2 //a right-to-left binary method let exp_rl_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (get_ith_bit bBits b i = 0) then acc else mul acc c in let c = mul c c in (acc, c) let exp_rl (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_rl k a bBits b == pow k a b) //a left-to-right binary method let exp_lr_f (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (acc:t) : t = let acc = mul acc acc in let acc = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then acc else mul acc a in acc let exp_lr (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = Loops.repeati bBits (exp_lr_f k a bBits b) one val exp_lr_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_lr k a bBits b == pow k a b) // Montgomery ladder for exponentiation let exp_mont_ladder_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = if (get_ith_bit bBits b (bBits - 1 - i) = 0) then (mul r0 r0, mul r1 r0) else (mul r0 r1, mul r1 r1) let exp_mont_ladder (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in r0 val exp_mont_ladder_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder k a bBits b == pow k a b) // Montgomery ladder for exponentiation with cswap let cswap (#t:Type) (sw:nat) (r0:t) (r1:t) : tuple2 t t = if sw = 1 then (r1, r0) else (r0, r1) // cswap -> step -> cswap -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap2_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1) : tuple2 t t) : tuple2 t t = let bit = get_ith_bit bBits b (bBits - 1 - i) in let r0, r1 = cswap bit r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in let r0, r1 = cswap bit r0 r1 in (r0, r1) let exp_mont_ladder_swap2 (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_swap2_f k bBits b) (one, a) in r0 val exp_mont_ladder_swap2_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap2 k a bBits b == exp_mont_ladder k a bBits b) // cswap -> step -> cswap -> step -> cswap -> .. let exp_mont_ladder_swap_f (#t:Type) (k:comm_monoid t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = cswap sw r0 r1 in let r0, r1 = (mul r0 r0, mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:comm_monoid t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one, a, 0) in let (r0, r1) = cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (exp_mont_ladder_swap k a bBits b == exp_mont_ladder k a bBits b) // a fixed window method let exp_pow2 (#t:Type) (k:comm_monoid t) (a:t) (b:nat) : t = Loops.repeat b (sqr k) a val exp_pow2_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> Lemma (exp_pow2 k a b == pow k a (pow2 b)) let get_ith_lbits (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) (l:pos) = b / pow2 i % pow2 l
false
false
Lib.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bits_l (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) : r: nat{r < pow2 l}
[]
Lib.Exponentiation.get_bits_l
{ "file_name": "lib/Lib.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i < bBits / l} -> r: Prims.nat{r < Prims.pow2 l}
{ "end_col": 57, "end_line": 106, "start_col": 2, "start_line": 104 }
Prims.Tot
val size32_u16_le:size32 serialize_u16_le
[ { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_u16_le: size32 serialize_u16_le = assert_norm (size32_constant_precond serialize_u16_le 2ul); size32_constant serialize_u16_le 2ul ()
val size32_u16_le:size32 serialize_u16_le let size32_u16_le:size32 serialize_u16_le =
false
null
false
assert_norm (size32_constant_precond serialize_u16_le 2ul); size32_constant serialize_u16_le 2ul ()
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "LowParse.SLow.Base.size32_constant", "LowParse.Spec.Int.parse_u16_kind", "FStar.UInt16.t", "LowParse.Spec.BoundedInt.parse_u16_le", "LowParse.Spec.BoundedInt.serialize_u16_le", "FStar.UInt32.__uint_to_t", "Prims.unit", "FStar.Pervasives.assert_norm", "LowParse.SLow.Base.size32_constant_precond" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4 inline_for_extraction val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) inline_for_extraction noextract let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) = match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4 #push-options "--max_fuel 0" inline_for_extraction val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1) inline_for_extraction val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2) inline_for_extraction val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3) inline_for_extraction val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4) inline_for_extraction noextract let parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = match sz with | 1 -> parse32_bounded_integer_le_1 | 2 -> parse32_bounded_integer_le_2 | 3 -> parse32_bounded_integer_le_3 | 4 -> parse32_bounded_integer_le_4 inline_for_extraction val parse32_u16_le : parser32 parse_u16_le inline_for_extraction val parse32_u32_le : parser32 parse_u32_le #pop-options inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction noextract let serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz)) = match sz with | 1 -> serialize32_bounded_integer_le_1 | 2 -> serialize32_bounded_integer_le_2 | 3 -> serialize32_bounded_integer_le_3 | 4 -> serialize32_bounded_integer_le_4 inline_for_extraction val serialize32_u16_le : serializer32 serialize_u16_le inline_for_extraction val serialize32_u32_le : serializer32 serialize_u32_le inline_for_extraction
false
true
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_u16_le:size32 serialize_u16_le
[]
LowParse.SLow.BoundedInt.size32_u16_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.size32 LowParse.Spec.BoundedInt.serialize_u16_le
{ "end_col": 41, "end_line": 124, "start_col": 2, "start_line": 123 }
Prims.Tot
val size32_u32_le:size32 serialize_u32_le
[ { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_u32_le: size32 serialize_u32_le = assert_norm (size32_constant_precond serialize_u32_le 4ul); size32_constant serialize_u32_le 4ul ()
val size32_u32_le:size32 serialize_u32_le let size32_u32_le:size32 serialize_u32_le =
false
null
false
assert_norm (size32_constant_precond serialize_u32_le 4ul); size32_constant serialize_u32_le 4ul ()
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "LowParse.SLow.Base.size32_constant", "LowParse.Spec.Int.parse_u32_kind", "FStar.UInt32.t", "LowParse.Spec.BoundedInt.parse_u32_le", "LowParse.Spec.BoundedInt.serialize_u32_le", "FStar.UInt32.__uint_to_t", "Prims.unit", "FStar.Pervasives.assert_norm", "LowParse.SLow.Base.size32_constant_precond" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4 inline_for_extraction val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) inline_for_extraction noextract let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) = match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4 #push-options "--max_fuel 0" inline_for_extraction val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1) inline_for_extraction val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2) inline_for_extraction val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3) inline_for_extraction val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4) inline_for_extraction noextract let parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = match sz with | 1 -> parse32_bounded_integer_le_1 | 2 -> parse32_bounded_integer_le_2 | 3 -> parse32_bounded_integer_le_3 | 4 -> parse32_bounded_integer_le_4 inline_for_extraction val parse32_u16_le : parser32 parse_u16_le inline_for_extraction val parse32_u32_le : parser32 parse_u32_le #pop-options inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction noextract let serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz)) = match sz with | 1 -> serialize32_bounded_integer_le_1 | 2 -> serialize32_bounded_integer_le_2 | 3 -> serialize32_bounded_integer_le_3 | 4 -> serialize32_bounded_integer_le_4 inline_for_extraction val serialize32_u16_le : serializer32 serialize_u16_le inline_for_extraction val serialize32_u32_le : serializer32 serialize_u32_le inline_for_extraction let size32_u16_le: size32 serialize_u16_le = assert_norm (size32_constant_precond serialize_u16_le 2ul); size32_constant serialize_u16_le 2ul () inline_for_extraction
false
true
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_u32_le:size32 serialize_u32_le
[]
LowParse.SLow.BoundedInt.size32_u32_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.size32 LowParse.Spec.BoundedInt.serialize_u32_le
{ "end_col": 41, "end_line": 129, "start_col": 2, "start_line": 128 }
Prims.Tot
val parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz))
[ { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = match sz with | 1 -> parse32_bounded_integer_le_1 | 2 -> parse32_bounded_integer_le_2 | 3 -> parse32_bounded_integer_le_3 | 4 -> parse32_bounded_integer_le_4
val parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) let parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
false
null
false
match sz with | 1 -> parse32_bounded_integer_le_1 | 2 -> parse32_bounded_integer_le_2 | 3 -> parse32_bounded_integer_le_3 | 4 -> parse32_bounded_integer_le_4
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.SLow.BoundedInt.parse32_bounded_integer_le_1", "LowParse.SLow.BoundedInt.parse32_bounded_integer_le_2", "LowParse.SLow.BoundedInt.parse32_bounded_integer_le_3", "LowParse.SLow.BoundedInt.parse32_bounded_integer_le_4", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer_le" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4 inline_for_extraction val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) inline_for_extraction noextract let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) = match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4 #push-options "--max_fuel 0" inline_for_extraction val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1) inline_for_extraction val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2) inline_for_extraction val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3) inline_for_extraction val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4) inline_for_extraction noextract
false
false
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz))
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le sz)
{ "end_col": 37, "end_line": 84, "start_col": 2, "start_line": 80 }
Prims.Tot
val parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz))
[ { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4
val parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
false
null
false
match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.SLow.BoundedInt.parse32_bounded_integer_1", "LowParse.SLow.BoundedInt.parse32_bounded_integer_2", "LowParse.SLow.BoundedInt.parse32_bounded_integer_3", "LowParse.SLow.BoundedInt.parse32_bounded_integer_4", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract
false
false
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz))
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer sz)
{ "end_col": 34, "end_line": 30, "start_col": 2, "start_line": 26 }
Prims.Tot
val serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz))
[ { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) = match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4
val serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) =
false
null
false
match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_1", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_2", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_3", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_4", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4 inline_for_extraction val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) inline_for_extraction noextract let serialize32_bounded_integer (sz: integer_size)
false
false
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer sz)
{ "end_col": 38, "end_line": 57, "start_col": 2, "start_line": 53 }
Prims.Tot
val serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz))
[ { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz)) = match sz with | 1 -> serialize32_bounded_integer_le_1 | 2 -> serialize32_bounded_integer_le_2 | 3 -> serialize32_bounded_integer_le_3 | 4 -> serialize32_bounded_integer_le_4
val serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz)) let serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz)) =
false
null
false
match sz with | 1 -> serialize32_bounded_integer_le_1 | 2 -> serialize32_bounded_integer_le_2 | 3 -> serialize32_bounded_integer_le_3 | 4 -> serialize32_bounded_integer_le_4
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_1", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_2", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_3", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_4", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4 inline_for_extraction val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) inline_for_extraction noextract let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) = match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4 #push-options "--max_fuel 0" inline_for_extraction val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1) inline_for_extraction val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2) inline_for_extraction val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3) inline_for_extraction val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4) inline_for_extraction noextract let parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = match sz with | 1 -> parse32_bounded_integer_le_1 | 2 -> parse32_bounded_integer_le_2 | 3 -> parse32_bounded_integer_le_3 | 4 -> parse32_bounded_integer_le_4 inline_for_extraction val parse32_u16_le : parser32 parse_u16_le inline_for_extraction val parse32_u32_le : parser32 parse_u32_le #pop-options inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction noextract
false
false
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer_le sz)
{ "end_col": 41, "end_line": 113, "start_col": 2, "start_line": 109 }
Prims.Tot
val parse32_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then parse32_bounded_int32_1 min32 max32 input else if max32 `U32.lt` 65536ul then parse32_bounded_int32_2 min32 max32 input else if max32 `U32.lt` 16777216ul then parse32_bounded_int32_3 min32 max32 input else parse32_bounded_int32_4 min32 max32 input )
val parse32_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) let parse32_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) =
false
null
false
fun input -> (if max32 `U32.lt` 256ul then parse32_bounded_int32_1 min32 max32 input else if max32 `U32.lt` 65536ul then parse32_bounded_int32_2 min32 max32 input else if max32 `U32.lt` 16777216ul then parse32_bounded_int32_3 min32 max32 input else parse32_bounded_int32_4 min32 max32 input)
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.SLow.Base.bytes32", "FStar.UInt32.lt", "FStar.UInt32.__uint_to_t", "LowParse.SLow.BoundedInt.parse32_bounded_int32_1", "Prims.bool", "LowParse.SLow.BoundedInt.parse32_bounded_int32_2", "LowParse.SLow.BoundedInt.parse32_bounded_int32_3", "LowParse.SLow.BoundedInt.parse32_bounded_int32_4", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32", "LowParse.SLow.Base.parser32" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4 inline_for_extraction val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) inline_for_extraction noextract let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) = match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4 #push-options "--max_fuel 0" inline_for_extraction val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1) inline_for_extraction val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2) inline_for_extraction val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3) inline_for_extraction val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4) inline_for_extraction noextract let parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = match sz with | 1 -> parse32_bounded_integer_le_1 | 2 -> parse32_bounded_integer_le_2 | 3 -> parse32_bounded_integer_le_3 | 4 -> parse32_bounded_integer_le_4 inline_for_extraction val parse32_u16_le : parser32 parse_u16_le inline_for_extraction val parse32_u32_le : parser32 parse_u32_le #pop-options inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction noextract let serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz)) = match sz with | 1 -> serialize32_bounded_integer_le_1 | 2 -> serialize32_bounded_integer_le_2 | 3 -> serialize32_bounded_integer_le_3 | 4 -> serialize32_bounded_integer_le_4 inline_for_extraction val serialize32_u16_le : serializer32 serialize_u16_le inline_for_extraction val serialize32_u32_le : serializer32 serialize_u32_le inline_for_extraction let size32_u16_le: size32 serialize_u16_le = assert_norm (size32_constant_precond serialize_u16_le 2ul); size32_constant serialize_u16_le 2ul () inline_for_extraction let size32_u32_le: size32 serialize_u32_le = assert_norm (size32_constant_precond serialize_u32_le 4ul); size32_constant serialize_u32_le 4ul () module U32 = FStar.UInt32 val parse32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let parse32_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
false
false
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 3, "end_line": 166, "start_col": 2, "start_line": 158 }
Prims.Tot
val parse32_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then parse32_bounded_int32_le_1 min32 max32 input else if max32 `U32.lt` 65536ul then parse32_bounded_int32_le_2 min32 max32 input else if max32 `U32.lt` 16777216ul then parse32_bounded_int32_le_3 min32 max32 input else parse32_bounded_int32_le_4 min32 max32 input )
val parse32_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) let parse32_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) =
false
null
false
fun input -> (if max32 `U32.lt` 256ul then parse32_bounded_int32_le_1 min32 max32 input else if max32 `U32.lt` 65536ul then parse32_bounded_int32_le_2 min32 max32 input else if max32 `U32.lt` 16777216ul then parse32_bounded_int32_le_3 min32 max32 input else parse32_bounded_int32_le_4 min32 max32 input)
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.SLow.Base.bytes32", "FStar.UInt32.lt", "FStar.UInt32.__uint_to_t", "LowParse.SLow.BoundedInt.parse32_bounded_int32_le_1", "Prims.bool", "LowParse.SLow.BoundedInt.parse32_bounded_int32_le_2", "LowParse.SLow.BoundedInt.parse32_bounded_int32_le_3", "LowParse.SLow.BoundedInt.parse32_bounded_int32_le_4", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32_le", "LowParse.SLow.Base.parser32" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4 inline_for_extraction val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) inline_for_extraction noextract let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) = match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4 #push-options "--max_fuel 0" inline_for_extraction val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1) inline_for_extraction val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2) inline_for_extraction val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3) inline_for_extraction val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4) inline_for_extraction noextract let parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = match sz with | 1 -> parse32_bounded_integer_le_1 | 2 -> parse32_bounded_integer_le_2 | 3 -> parse32_bounded_integer_le_3 | 4 -> parse32_bounded_integer_le_4 inline_for_extraction val parse32_u16_le : parser32 parse_u16_le inline_for_extraction val parse32_u32_le : parser32 parse_u32_le #pop-options inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction noextract let serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz)) = match sz with | 1 -> serialize32_bounded_integer_le_1 | 2 -> serialize32_bounded_integer_le_2 | 3 -> serialize32_bounded_integer_le_3 | 4 -> serialize32_bounded_integer_le_4 inline_for_extraction val serialize32_u16_le : serializer32 serialize_u16_le inline_for_extraction val serialize32_u32_le : serializer32 serialize_u32_le inline_for_extraction let size32_u16_le: size32 serialize_u16_le = assert_norm (size32_constant_precond serialize_u16_le 2ul); size32_constant serialize_u16_le 2ul () inline_for_extraction let size32_u32_le: size32 serialize_u32_le = assert_norm (size32_constant_precond serialize_u32_le 4ul); size32_constant serialize_u32_le 4ul () module U32 = FStar.UInt32 val parse32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let parse32_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then parse32_bounded_int32_1 min32 max32 input else if max32 `U32.lt` 65536ul then parse32_bounded_int32_2 min32 max32 input else if max32 `U32.lt` 16777216ul then parse32_bounded_int32_3 min32 max32 input else parse32_bounded_int32_4 min32 max32 input ) val serialize32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let serialize32_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then serialize32_bounded_int32_1 min32 max32 input else if max32 `U32.lt` 65536ul then serialize32_bounded_int32_2 min32 max32 input else if max32 `U32.lt` 16777216ul then serialize32_bounded_int32_3 min32 max32 input else serialize32_bounded_int32_4 min32 max32 input ) val parse32_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val parse32_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val parse32_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val parse32_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let parse32_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
false
false
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 3, "end_line": 237, "start_col": 2, "start_line": 229 }
Prims.Tot
val serialize32_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then serialize32_bounded_int32_1 min32 max32 input else if max32 `U32.lt` 65536ul then serialize32_bounded_int32_2 min32 max32 input else if max32 `U32.lt` 16777216ul then serialize32_bounded_int32_3 min32 max32 input else serialize32_bounded_int32_4 min32 max32 input )
val serialize32_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) let serialize32_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) =
false
null
false
fun input -> (if max32 `U32.lt` 256ul then serialize32_bounded_int32_1 min32 max32 input else if max32 `U32.lt` 65536ul then serialize32_bounded_int32_2 min32 max32 input else if max32 `U32.lt` 16777216ul then serialize32_bounded_int32_3 min32 max32 input else serialize32_bounded_int32_4 min32 max32 input)
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Spec.BoundedInt.bounded_int32", "FStar.UInt32.lt", "FStar.UInt32.__uint_to_t", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_1", "Prims.bool", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_2", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_3", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_4", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32", "LowParse.Spec.BoundedInt.serialize_bounded_int32", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4 inline_for_extraction val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) inline_for_extraction noextract let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) = match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4 #push-options "--max_fuel 0" inline_for_extraction val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1) inline_for_extraction val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2) inline_for_extraction val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3) inline_for_extraction val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4) inline_for_extraction noextract let parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = match sz with | 1 -> parse32_bounded_integer_le_1 | 2 -> parse32_bounded_integer_le_2 | 3 -> parse32_bounded_integer_le_3 | 4 -> parse32_bounded_integer_le_4 inline_for_extraction val parse32_u16_le : parser32 parse_u16_le inline_for_extraction val parse32_u32_le : parser32 parse_u32_le #pop-options inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction noextract let serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz)) = match sz with | 1 -> serialize32_bounded_integer_le_1 | 2 -> serialize32_bounded_integer_le_2 | 3 -> serialize32_bounded_integer_le_3 | 4 -> serialize32_bounded_integer_le_4 inline_for_extraction val serialize32_u16_le : serializer32 serialize_u16_le inline_for_extraction val serialize32_u32_le : serializer32 serialize_u32_le inline_for_extraction let size32_u16_le: size32 serialize_u16_le = assert_norm (size32_constant_precond serialize_u16_le 2ul); size32_constant serialize_u16_le 2ul () inline_for_extraction let size32_u32_le: size32 serialize_u32_le = assert_norm (size32_constant_precond serialize_u32_le 4ul); size32_constant serialize_u32_le 4ul () module U32 = FStar.UInt32 val parse32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let parse32_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then parse32_bounded_int32_1 min32 max32 input else if max32 `U32.lt` 65536ul then parse32_bounded_int32_2 min32 max32 input else if max32 `U32.lt` 16777216ul then parse32_bounded_int32_3 min32 max32 input else parse32_bounded_int32_4 min32 max32 input ) val serialize32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let serialize32_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
false
false
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 3, "end_line": 201, "start_col": 2, "start_line": 193 }
Prims.Tot
val serialize32_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then serialize32_bounded_int32_le_1 min32 max32 input else if max32 `U32.lt` 65536ul then serialize32_bounded_int32_le_2 min32 max32 input else if max32 `U32.lt` 16777216ul then serialize32_bounded_int32_le_3 min32 max32 input else serialize32_bounded_int32_le_4 min32 max32 input )
val serialize32_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) =
false
null
false
fun input -> (if max32 `U32.lt` 256ul then serialize32_bounded_int32_le_1 min32 max32 input else if max32 `U32.lt` 65536ul then serialize32_bounded_int32_le_2 min32 max32 input else if max32 `U32.lt` 16777216ul then serialize32_bounded_int32_le_3 min32 max32 input else serialize32_bounded_int32_le_4 min32 max32 input)
{ "checked_file": "LowParse.SLow.BoundedInt.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.BoundedInt.fsti" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Spec.BoundedInt.bounded_int32", "FStar.UInt32.lt", "FStar.UInt32.__uint_to_t", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_1", "Prims.bool", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_2", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_3", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_4", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32_le", "LowParse.Spec.BoundedInt.serialize_bounded_int32_le", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.BoundedInt include LowParse.Spec.BoundedInt include LowParse.SLow.Base (* bounded integers *) inline_for_extraction val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) inline_for_extraction val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) inline_for_extraction val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) inline_for_extraction val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) inline_for_extraction noextract let parse32_bounded_integer (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = match sz with | 1 -> parse32_bounded_integer_1 | 2 -> parse32_bounded_integer_2 | 3 -> parse32_bounded_integer_3 | 4 -> parse32_bounded_integer_4 inline_for_extraction val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) inline_for_extraction noextract let serialize32_bounded_integer (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer sz)) = match sz with | 1 -> serialize32_bounded_integer_1 | 2 -> serialize32_bounded_integer_2 | 3 -> serialize32_bounded_integer_3 | 4 -> serialize32_bounded_integer_4 #push-options "--max_fuel 0" inline_for_extraction val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1) inline_for_extraction val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2) inline_for_extraction val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3) inline_for_extraction val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4) inline_for_extraction noextract let parse32_bounded_integer_le (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = match sz with | 1 -> parse32_bounded_integer_le_1 | 2 -> parse32_bounded_integer_le_2 | 3 -> parse32_bounded_integer_le_3 | 4 -> parse32_bounded_integer_le_4 inline_for_extraction val parse32_u16_le : parser32 parse_u16_le inline_for_extraction val parse32_u32_le : parser32 parse_u32_le #pop-options inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction noextract let serialize32_bounded_integer_le (sz: integer_size) : Tot (serializer32 (serialize_bounded_integer_le sz)) = match sz with | 1 -> serialize32_bounded_integer_le_1 | 2 -> serialize32_bounded_integer_le_2 | 3 -> serialize32_bounded_integer_le_3 | 4 -> serialize32_bounded_integer_le_4 inline_for_extraction val serialize32_u16_le : serializer32 serialize_u16_le inline_for_extraction val serialize32_u32_le : serializer32 serialize_u32_le inline_for_extraction let size32_u16_le: size32 serialize_u16_le = assert_norm (size32_constant_precond serialize_u16_le 2ul); size32_constant serialize_u16_le 2ul () inline_for_extraction let size32_u32_le: size32 serialize_u32_le = assert_norm (size32_constant_precond serialize_u32_le 4ul); size32_constant serialize_u32_le 4ul () module U32 = FStar.UInt32 val parse32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) val parse32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let parse32_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then parse32_bounded_int32_1 min32 max32 input else if max32 `U32.lt` 65536ul then parse32_bounded_int32_2 min32 max32 input else if max32 `U32.lt` 16777216ul then parse32_bounded_int32_3 min32 max32 input else parse32_bounded_int32_4 min32 max32 input ) val serialize32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let serialize32_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then serialize32_bounded_int32_1 min32 max32 input else if max32 `U32.lt` 65536ul then serialize32_bounded_int32_2 min32 max32 input else if max32 `U32.lt` 16777216ul then serialize32_bounded_int32_3 min32 max32 input else serialize32_bounded_int32_4 min32 max32 input ) val parse32_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val parse32_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val parse32_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val parse32_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let parse32_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun input -> ( if max32 `U32.lt` 256ul then parse32_bounded_int32_le_1 min32 max32 input else if max32 `U32.lt` 65536ul then parse32_bounded_int32_le_2 min32 max32 input else if max32 `U32.lt` 16777216ul then parse32_bounded_int32_le_3 min32 max32 input else parse32_bounded_int32_le_4 min32 max32 input ) val serialize32_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val serialize32_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let serialize32_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
false
false
LowParse.SLow.BoundedInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32_le (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 3, "end_line": 272, "start_col": 2, "start_line": 264 }
Prims.Tot
val lowerUpper128u (l u: uint_t 64) : uint_t 128
[ { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowerUpper128u (l:uint_t 64) (u:uint_t 64) : uint_t 128 = 0x10000000000000000 * u + l
val lowerUpper128u (l u: uint_t 64) : uint_t 128 let lowerUpper128u (l u: uint_t 64) : uint_t 128 =
false
null
false
0x10000000000000000 * u + l
{ "checked_file": "Vale.Poly1305.Bitvectors.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.BV.fsti.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Bitvectors.fsti" }
[ "total" ]
[ "FStar.UInt.uint_t", "Prims.op_Addition", "FStar.Mul.op_Star" ]
[]
module Vale.Poly1305.Bitvectors open FStar.BV open FStar.Mul open FStar.UInt val lemma_shr2: (x:uint_t 64) -> Lemma ((shift_right #64 x 2 == udiv #64 x 4)) [SMTPat (shift_right #64 x 2)] val lemma_shr4: x:uint_t 64 -> Lemma (shift_right #64 x 4 == udiv #64 x 16) [SMTPat (shift_right #64 x 4)] val lemma_and_mod_n: x:uint_t 64 -> Lemma (logand #64 x 3 == mod #64 x 4 /\ logand #64 x 15 == mod #64 x 16) [SMTPat (logand #64 x 3); SMTPat (logand #64 x 15)] val lemma_clear_lower_2: x:uint_t 64 -> Lemma (logand #64 x 0xfffffffffffffffc == mul_mod #64 (udiv #64 x 4) 4) [SMTPat (logand #64 x 0xfffffffffffffffc)] val lemma_and_constants: x:uint_t 64 -> Lemma (logand #64 x 0 == 0 /\ logand #64 x 0xffffffffffffffff == x) [SMTPat (logand #64 x 0); SMTPat (logand #64 x 0xffffffffffffffff)] val lemma_poly_constants: x:uint_t 64 -> Lemma (logand #64 x 0x0ffffffc0fffffff < 0x1000000000000000 /\ logand #64 x 0x0ffffffc0ffffffc < 0x1000000000000000 /\ mod #64 (logand #64 x 0x0ffffffc0ffffffc) 4 == 0) [SMTPat (logand #64 x 0x0ffffffc0fffffff); SMTPat (logand #64 x 0x0ffffffc0ffffffc); SMTPat (logand #64 x 0x0ffffffc0ffffffc)] val lemma_and_commutes: x:uint_t 64 -> y:uint_t 64 -> Lemma (logand #64 x y == logand #64 y x) val lemma_bv128_64_64_and_helper: x:bv_t 128 -> x0:bv_t 64 -> x1:bv_t 64 -> y:bv_t 128 -> y0:bv_t 64 -> y1:bv_t 64 -> z:bv_t 128 -> z0:bv_t 64 -> z1:bv_t 64 -> Lemma (requires (z0 == bvand #64 x0 y0 /\ z1 == bvand #64 x1 y1 /\ x == bvor #128 (bvshl #128 (bv_uext #64 #64 x1) 64) (bv_uext #64 #64 x0) /\ y == bvor #128 (bvshl #128 (bv_uext #64 #64 y1) 64) (bv_uext #64 #64 y0) /\ z == bvor #128 (bvshl #128 (bv_uext #64 #64 z1) 64) (bv_uext #64 #64 z0))) (ensures (z == bvand #128 x y)) val bv128_64_64: x1:bv_t 64 -> x0:bv_t 64 -> Tot (bv_t 128) val lemma_bv128_64_64_and: x:bv_t 128 -> x0:bv_t 64 -> x1:bv_t 64 -> y:bv_t 128 -> y0:bv_t 64 -> y1:bv_t 64 -> z:bv_t 128 -> z0:bv_t 64 -> z1:bv_t 64 -> Lemma (requires (z0 == bvand #64 x0 y0 /\ z1 == bvand #64 x1 y1 /\ x == bv128_64_64 x0 x1 /\ y == bv128_64_64 y0 y1 /\ z == bv128_64_64 z0 z1)) (ensures (z == bvand #128 x y))
false
false
Vale.Poly1305.Bitvectors.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowerUpper128u (l u: uint_t 64) : uint_t 128
[]
Vale.Poly1305.Bitvectors.lowerUpper128u
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Bitvectors.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: FStar.UInt.uint_t 64 -> u3: FStar.UInt.uint_t 64 -> FStar.UInt.uint_t 128
{ "end_col": 31, "end_line": 57, "start_col": 4, "start_line": 57 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.Low.Datastructures", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "EHS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "Spec.Hash.Definitions", "short_module": "Hash" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MLH" }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree.Low", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MTLH" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mt_p = MerkleTree.Low.mt_p
let mt_p =
false
null
false
MerkleTree.Low.mt_p
{ "checked_file": "MerkleTree.EverCrypt.fsti.checked", "dependencies": [ "prims.fst.checked", "MerkleTree.New.High.fst.checked", "MerkleTree.Low.Hashfunctions.fst.checked", "MerkleTree.Low.Datastructures.fst.checked", "MerkleTree.Low.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.EverCrypt.fsti" }
[ "total" ]
[ "MerkleTree.Low.mt_p" ]
[]
module MerkleTree.EverCrypt module HH = FStar.Monotonic.HyperHeap module B = LowStar.Buffer module HST = FStar.HyperStack.ST module MTH = MerkleTree.New.High module MTLH = MerkleTree.Low.Hashfunctions module MTLD = MerkleTree.Low.Datastructures open LowStar.Regional #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// A declaration whose sole purpose is to align the .fsti with the .fst noextract val _align : unit inline_for_extraction noextract let hash #hash_size = MTLD.hash #hash_size
false
true
MerkleTree.EverCrypt.fsti
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mt_p : Type0
[]
MerkleTree.EverCrypt.mt_p
{ "file_name": "src/MerkleTree.EverCrypt.fsti", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
Type0
{ "end_col": 30, "end_line": 21, "start_col": 11, "start_line": 21 }
Prims.GTot
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.Low.Datastructures", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "EHS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "Spec.Hash.Definitions", "short_module": "Hash" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MLH" }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree.Low", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MTLH" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mt_safe = MerkleTree.Low.mt_safe
let mt_safe =
false
null
false
MerkleTree.Low.mt_safe
{ "checked_file": "MerkleTree.EverCrypt.fsti.checked", "dependencies": [ "prims.fst.checked", "MerkleTree.New.High.fst.checked", "MerkleTree.Low.Hashfunctions.fst.checked", "MerkleTree.Low.Datastructures.fst.checked", "MerkleTree.Low.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.EverCrypt.fsti" }
[ "sometrivial" ]
[ "MerkleTree.Low.mt_safe" ]
[]
module MerkleTree.EverCrypt module HH = FStar.Monotonic.HyperHeap module B = LowStar.Buffer module HST = FStar.HyperStack.ST module MTH = MerkleTree.New.High module MTLH = MerkleTree.Low.Hashfunctions module MTLD = MerkleTree.Low.Datastructures open LowStar.Regional #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// A declaration whose sole purpose is to align the .fsti with the .fst noextract val _align : unit inline_for_extraction noextract let hash #hash_size = MTLD.hash #hash_size inline_for_extraction noextract let mt_p = MerkleTree.Low.mt_p inline_for_extraction noextract let mt_loc = MerkleTree.Low.mt_loc
false
false
MerkleTree.EverCrypt.fsti
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mt_safe : h: FStar.Monotonic.HyperStack.mem -> mt: MerkleTree.Low.mt_p -> Prims.GTot Type0
[]
MerkleTree.EverCrypt.mt_safe
{ "file_name": "src/MerkleTree.EverCrypt.fsti", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
h: FStar.Monotonic.HyperStack.mem -> mt: MerkleTree.Low.mt_p -> Prims.GTot Type0
{ "end_col": 36, "end_line": 25, "start_col": 14, "start_line": 25 }
Prims.GTot
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.Low.Datastructures", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "EHS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "Spec.Hash.Definitions", "short_module": "Hash" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MLH" }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree.Low", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MTLH" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mt_loc = MerkleTree.Low.mt_loc
let mt_loc =
false
null
false
MerkleTree.Low.mt_loc
{ "checked_file": "MerkleTree.EverCrypt.fsti.checked", "dependencies": [ "prims.fst.checked", "MerkleTree.New.High.fst.checked", "MerkleTree.Low.Hashfunctions.fst.checked", "MerkleTree.Low.Datastructures.fst.checked", "MerkleTree.Low.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.EverCrypt.fsti" }
[ "sometrivial" ]
[ "MerkleTree.Low.mt_loc" ]
[]
module MerkleTree.EverCrypt module HH = FStar.Monotonic.HyperHeap module B = LowStar.Buffer module HST = FStar.HyperStack.ST module MTH = MerkleTree.New.High module MTLH = MerkleTree.Low.Hashfunctions module MTLD = MerkleTree.Low.Datastructures open LowStar.Regional #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// A declaration whose sole purpose is to align the .fsti with the .fst noextract val _align : unit inline_for_extraction noextract let hash #hash_size = MTLD.hash #hash_size inline_for_extraction noextract let mt_p = MerkleTree.Low.mt_p
false
false
MerkleTree.EverCrypt.fsti
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mt_loc : mt: MerkleTree.Low.mt_p -> Prims.GTot LowStar.Monotonic.Buffer.loc
[]
MerkleTree.EverCrypt.mt_loc
{ "file_name": "src/MerkleTree.EverCrypt.fsti", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
mt: MerkleTree.Low.mt_p -> Prims.GTot LowStar.Monotonic.Buffer.loc
{ "end_col": 34, "end_line": 23, "start_col": 13, "start_line": 23 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.Low.Datastructures", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "EHS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "Spec.Hash.Definitions", "short_module": "Hash" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MLH" }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree.Low", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MTLH" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let hash #hash_size = MTLD.hash #hash_size
let hash #hash_size =
false
null
false
MTLD.hash #hash_size
{ "checked_file": "MerkleTree.EverCrypt.fsti.checked", "dependencies": [ "prims.fst.checked", "MerkleTree.New.High.fst.checked", "MerkleTree.Low.Hashfunctions.fst.checked", "MerkleTree.Low.Datastructures.fst.checked", "MerkleTree.Low.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.EverCrypt.fsti" }
[ "total" ]
[ "MerkleTree.Low.Datastructures.hash_size_t", "MerkleTree.Low.Datastructures.hash" ]
[]
module MerkleTree.EverCrypt module HH = FStar.Monotonic.HyperHeap module B = LowStar.Buffer module HST = FStar.HyperStack.ST module MTH = MerkleTree.New.High module MTLH = MerkleTree.Low.Hashfunctions module MTLD = MerkleTree.Low.Datastructures open LowStar.Regional #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// A declaration whose sole purpose is to align the .fsti with the .fst noextract val _align : unit
false
true
MerkleTree.EverCrypt.fsti
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hash : Type0
[]
MerkleTree.EverCrypt.hash
{ "file_name": "src/MerkleTree.EverCrypt.fsti", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
Type0
{ "end_col": 42, "end_line": 19, "start_col": 22, "start_line": 19 }
Prims.GTot
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.Low.Datastructures", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "EHS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "Spec.Hash.Definitions", "short_module": "Hash" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MLH" }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree.Low", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Low.Datastructures", "short_module": "MTLD" }, { "abbrev": true, "full_module": "MerkleTree.Low.Hashfunctions", "short_module": "MTLH" }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mt_lift = MerkleTree.Low.mt_lift
let mt_lift =
false
null
false
MerkleTree.Low.mt_lift
{ "checked_file": "MerkleTree.EverCrypt.fsti.checked", "dependencies": [ "prims.fst.checked", "MerkleTree.New.High.fst.checked", "MerkleTree.Low.Hashfunctions.fst.checked", "MerkleTree.Low.Datastructures.fst.checked", "MerkleTree.Low.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.EverCrypt.fsti" }
[ "sometrivial" ]
[ "MerkleTree.Low.mt_lift" ]
[]
module MerkleTree.EverCrypt module HH = FStar.Monotonic.HyperHeap module B = LowStar.Buffer module HST = FStar.HyperStack.ST module MTH = MerkleTree.New.High module MTLH = MerkleTree.Low.Hashfunctions module MTLD = MerkleTree.Low.Datastructures open LowStar.Regional #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// A declaration whose sole purpose is to align the .fsti with the .fst noextract val _align : unit inline_for_extraction noextract let hash #hash_size = MTLD.hash #hash_size inline_for_extraction noextract let mt_p = MerkleTree.Low.mt_p inline_for_extraction noextract let mt_loc = MerkleTree.Low.mt_loc inline_for_extraction noextract let mt_safe = MerkleTree.Low.mt_safe
false
false
MerkleTree.EverCrypt.fsti
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mt_lift : h: FStar.Monotonic.HyperStack.mem -> mt: MerkleTree.Low.mt_p{MerkleTree.Low.mt_safe h mt} -> Prims.GTot (r: MerkleTree.New.High.merkle_tree{MerkleTree.New.High.mt_wf_elts r})
[]
MerkleTree.EverCrypt.mt_lift
{ "file_name": "src/MerkleTree.EverCrypt.fsti", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
h: FStar.Monotonic.HyperStack.mem -> mt: MerkleTree.Low.mt_p{MerkleTree.Low.mt_safe h mt} -> Prims.GTot (r: MerkleTree.New.High.merkle_tree{MerkleTree.New.High.mt_wf_elts r})
{ "end_col": 36, "end_line": 27, "start_col": 14, "start_line": 27 }
FStar.HyperStack.ST.Stack
val bn_is_odd: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_odd (as_seq h0 a))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Comparison", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_is_odd #t len a = a.(0ul) &. uint #t 1
val bn_is_odd: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_odd (as_seq h0 a)) let bn_is_odd #t len a =
true
null
false
a.(0ul) &. uint #t 1
{ "checked_file": "Hacl.Bignum.Comparison.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Comparison.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.SEC", "Lib.IntTypes.uint", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.int_t", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Bignum.Comparison open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions open Hacl.Bignum.Lib module S = Hacl.Spec.Bignum.Comparison module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Bignum comparison and test functions /// inline_for_extraction noextract val bn_is_odd: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_odd (as_seq h0 a))
false
false
Hacl.Bignum.Comparison.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_is_odd: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_odd (as_seq h0 a))
[]
Hacl.Bignum.Comparison.bn_is_odd
{ "file_name": "code/bignum/Hacl.Bignum.Comparison.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> a: Hacl.Bignum.Definitions.lbignum t len -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)
{ "end_col": 45, "end_line": 35, "start_col": 25, "start_line": 35 }
FStar.HyperStack.ST.Stack
val bn_is_zero_mask: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_zero_mask (as_seq h0 a))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Comparison", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_is_zero_mask #t len b = push_frame (); let bn_zero = create len (uint #t 0) in let res = bn_eq_mask len b bn_zero in pop_frame (); res
val bn_is_zero_mask: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_zero_mask (as_seq h0 a)) let bn_is_zero_mask #t len b =
true
null
false
push_frame (); let bn_zero = create len (uint #t 0) in let res = bn_eq_mask len b bn_zero in pop_frame (); res
{ "checked_file": "Hacl.Bignum.Comparison.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Comparison.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Bignum.Comparison.bn_eq_mask", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.Comparison open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions open Hacl.Bignum.Lib module S = Hacl.Spec.Bignum.Comparison module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Bignum comparison and test functions /// inline_for_extraction noextract val bn_is_odd: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_odd (as_seq h0 a)) let bn_is_odd #t len a = a.(0ul) &. uint #t 1 inline_for_extraction noextract val bn_eq_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b)) let bn_eq_mask #t len a b = push_frame (); let mask = create 1ul (ones t SEC) in let mask = Lib.ByteBuffer.buf_eq_mask a b len mask in pop_frame (); mask inline_for_extraction noextract val bn_is_zero_mask: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_zero_mask (as_seq h0 a))
false
false
Hacl.Bignum.Comparison.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_is_zero_mask: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_zero_mask (as_seq h0 a))
[]
Hacl.Bignum.Comparison.bn_is_zero_mask
{ "file_name": "code/bignum/Hacl.Bignum.Comparison.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> a: Hacl.Bignum.Definitions.lbignum t len -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)
{ "end_col": 5, "end_line": 72, "start_col": 2, "start_line": 68 }
FStar.HyperStack.ST.Stack
val bn_lt_pow2_mask: #t:limb_t -> len:size_t{0 < v len /\ bits t * v len <= max_size_t} -> b:lbignum t len -> x:size_t{v x < bits t * v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_pow2_mask (as_seq h0 b) (v x))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Comparison", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_lt_pow2_mask #t len b x = push_frame (); let b2 = create len (uint #t 0) in bn_set_ith_bit len b2 x; let res = bn_lt_mask len b b2 in pop_frame (); res
val bn_lt_pow2_mask: #t:limb_t -> len:size_t{0 < v len /\ bits t * v len <= max_size_t} -> b:lbignum t len -> x:size_t{v x < bits t * v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_pow2_mask (as_seq h0 b) (v x)) let bn_lt_pow2_mask #t len b x =
true
null
false
push_frame (); let b2 = create len (uint #t 0) in bn_set_ith_bit len b2 x; let res = bn_lt_mask len b b2 in pop_frame (); res
{ "checked_file": "Hacl.Bignum.Comparison.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Comparison.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Bignum.Comparison.bn_lt_mask", "Hacl.Bignum.Lib.bn_set_ith_bit", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.Comparison open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions open Hacl.Bignum.Lib module S = Hacl.Spec.Bignum.Comparison module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Bignum comparison and test functions /// inline_for_extraction noextract val bn_is_odd: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_odd (as_seq h0 a)) let bn_is_odd #t len a = a.(0ul) &. uint #t 1 inline_for_extraction noextract val bn_eq_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b)) let bn_eq_mask #t len a b = push_frame (); let mask = create 1ul (ones t SEC) in let mask = Lib.ByteBuffer.buf_eq_mask a b len mask in pop_frame (); mask inline_for_extraction noextract val bn_is_zero_mask: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_zero_mask (as_seq h0 a)) let bn_is_zero_mask #t len b = push_frame (); let bn_zero = create len (uint #t 0) in let res = bn_eq_mask len b bn_zero in pop_frame (); res inline_for_extraction noextract val bn_lt_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b)) let bn_lt_mask #t len a b = push_frame (); let acc = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (limb t) = Lib.Sequence.index (as_seq h acc) 0 in [@inline_let] let footprint i = loc acc in [@inline_let] let spec h = S.bn_lt_mask_f (as_seq h a) (as_seq h b) in let h0 = ST.get () in loop h0 len (S.bn_lt_mask_t t (v len)) refl footprint spec (fun i -> Loops.unfold_repeat_gen (v len) (S.bn_lt_mask_t t (v len)) (spec h0) (refl h0 0) (v i); let beq = eq_mask a.(i) b.(i) in let blt = lt_mask a.(i) b.(i) in acc.(0ul) <- mask_select beq acc.(0ul) (mask_select blt (ones t SEC) (zeros t SEC)) ); let mask = acc.(0ul) in pop_frame (); mask inline_for_extraction noextract val bn_lt_pow2_mask: #t:limb_t -> len:size_t{0 < v len /\ bits t * v len <= max_size_t} -> b:lbignum t len -> x:size_t{v x < bits t * v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_pow2_mask (as_seq h0 b) (v x))
false
false
Hacl.Bignum.Comparison.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_lt_pow2_mask: #t:limb_t -> len:size_t{0 < v len /\ bits t * v len <= max_size_t} -> b:lbignum t len -> x:size_t{v x < bits t * v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_pow2_mask (as_seq h0 b) (v x))
[]
Hacl.Bignum.Comparison.bn_lt_pow2_mask
{ "file_name": "code/bignum/Hacl.Bignum.Comparison.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.bits t * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t } -> b: Hacl.Bignum.Definitions.lbignum t len -> x: Lib.IntTypes.size_t{Lib.IntTypes.v x < Lib.IntTypes.bits t * Lib.IntTypes.v len} -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)
{ "end_col": 5, "end_line": 127, "start_col": 2, "start_line": 122 }
FStar.HyperStack.ST.Stack
val bn_gt_pow2_mask: #t:limb_t -> len:size_t{0 < v len /\ bits t * v len <= max_size_t} -> b:lbignum t len -> x:size_t{v x < bits t * v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_gt_pow2_mask (as_seq h0 b) (v x))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Comparison", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_gt_pow2_mask #t len b x = push_frame (); let b2 = create len (uint #t 0) in bn_set_ith_bit len b2 x; let res = bn_lt_mask len b2 b in pop_frame (); res
val bn_gt_pow2_mask: #t:limb_t -> len:size_t{0 < v len /\ bits t * v len <= max_size_t} -> b:lbignum t len -> x:size_t{v x < bits t * v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_gt_pow2_mask (as_seq h0 b) (v x)) let bn_gt_pow2_mask #t len b x =
true
null
false
push_frame (); let b2 = create len (uint #t 0) in bn_set_ith_bit len b2 x; let res = bn_lt_mask len b2 b in pop_frame (); res
{ "checked_file": "Hacl.Bignum.Comparison.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Comparison.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Bignum.Comparison.bn_lt_mask", "Hacl.Bignum.Lib.bn_set_ith_bit", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.Comparison open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions open Hacl.Bignum.Lib module S = Hacl.Spec.Bignum.Comparison module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Bignum comparison and test functions /// inline_for_extraction noextract val bn_is_odd: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_odd (as_seq h0 a)) let bn_is_odd #t len a = a.(0ul) &. uint #t 1 inline_for_extraction noextract val bn_eq_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b)) let bn_eq_mask #t len a b = push_frame (); let mask = create 1ul (ones t SEC) in let mask = Lib.ByteBuffer.buf_eq_mask a b len mask in pop_frame (); mask inline_for_extraction noextract val bn_is_zero_mask: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_zero_mask (as_seq h0 a)) let bn_is_zero_mask #t len b = push_frame (); let bn_zero = create len (uint #t 0) in let res = bn_eq_mask len b bn_zero in pop_frame (); res inline_for_extraction noextract val bn_lt_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b)) let bn_lt_mask #t len a b = push_frame (); let acc = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (limb t) = Lib.Sequence.index (as_seq h acc) 0 in [@inline_let] let footprint i = loc acc in [@inline_let] let spec h = S.bn_lt_mask_f (as_seq h a) (as_seq h b) in let h0 = ST.get () in loop h0 len (S.bn_lt_mask_t t (v len)) refl footprint spec (fun i -> Loops.unfold_repeat_gen (v len) (S.bn_lt_mask_t t (v len)) (spec h0) (refl h0 0) (v i); let beq = eq_mask a.(i) b.(i) in let blt = lt_mask a.(i) b.(i) in acc.(0ul) <- mask_select beq acc.(0ul) (mask_select blt (ones t SEC) (zeros t SEC)) ); let mask = acc.(0ul) in pop_frame (); mask inline_for_extraction noextract val bn_lt_pow2_mask: #t:limb_t -> len:size_t{0 < v len /\ bits t * v len <= max_size_t} -> b:lbignum t len -> x:size_t{v x < bits t * v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_pow2_mask (as_seq h0 b) (v x)) let bn_lt_pow2_mask #t len b x = push_frame (); let b2 = create len (uint #t 0) in bn_set_ith_bit len b2 x; let res = bn_lt_mask len b b2 in pop_frame (); res inline_for_extraction noextract val bn_gt_pow2_mask: #t:limb_t -> len:size_t{0 < v len /\ bits t * v len <= max_size_t} -> b:lbignum t len -> x:size_t{v x < bits t * v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_gt_pow2_mask (as_seq h0 b) (v x))
false
false
Hacl.Bignum.Comparison.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_gt_pow2_mask: #t:limb_t -> len:size_t{0 < v len /\ bits t * v len <= max_size_t} -> b:lbignum t len -> x:size_t{v x < bits t * v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_gt_pow2_mask (as_seq h0 b) (v x))
[]
Hacl.Bignum.Comparison.bn_gt_pow2_mask
{ "file_name": "code/bignum/Hacl.Bignum.Comparison.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.bits t * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t } -> b: Hacl.Bignum.Definitions.lbignum t len -> x: Lib.IntTypes.size_t{Lib.IntTypes.v x < Lib.IntTypes.bits t * Lib.IntTypes.v len} -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)
{ "end_col": 5, "end_line": 147, "start_col": 2, "start_line": 142 }
FStar.HyperStack.ST.Stack
val bn_lt_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Comparison", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_lt_mask #t len a b = push_frame (); let acc = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (limb t) = Lib.Sequence.index (as_seq h acc) 0 in [@inline_let] let footprint i = loc acc in [@inline_let] let spec h = S.bn_lt_mask_f (as_seq h a) (as_seq h b) in let h0 = ST.get () in loop h0 len (S.bn_lt_mask_t t (v len)) refl footprint spec (fun i -> Loops.unfold_repeat_gen (v len) (S.bn_lt_mask_t t (v len)) (spec h0) (refl h0 0) (v i); let beq = eq_mask a.(i) b.(i) in let blt = lt_mask a.(i) b.(i) in acc.(0ul) <- mask_select beq acc.(0ul) (mask_select blt (ones t SEC) (zeros t SEC)) ); let mask = acc.(0ul) in pop_frame (); mask
val bn_lt_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b)) let bn_lt_mask #t len a b =
true
null
false
push_frame (); let acc = create 1ul (uint #t 0) in [@@ inline_let ]let refl h i : GTot (limb t) = Lib.Sequence.index (as_seq h acc) 0 in [@@ inline_let ]let footprint i = loc acc in [@@ inline_let ]let spec h = S.bn_lt_mask_f (as_seq h a) (as_seq h b) in let h0 = ST.get () in loop h0 len (S.bn_lt_mask_t t (v len)) refl footprint spec (fun i -> Loops.unfold_repeat_gen (v len) (S.bn_lt_mask_t t (v len)) (spec h0) (refl h0 0) (v i); let beq = eq_mask a.(i) b.(i) in let blt = lt_mask a.(i) b.(i) in acc.(0ul) <- mask_select beq acc.(0ul) (mask_select blt (ones t SEC) (zeros t SEC))); let mask = acc.(0ul) in pop_frame (); mask
{ "checked_file": "Hacl.Bignum.Comparison.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Comparison.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "Lib.Buffer.loop", "Hacl.Spec.Bignum.Comparison.bn_lt_mask_t", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.b2t", "Prims.op_LessThan", "Lib.Buffer.op_Array_Assignment", "Hacl.Spec.Bignum.Base.mask_select", "Lib.IntTypes.ones", "Lib.IntTypes.SEC", "Lib.IntTypes.zeros", "Hacl.Spec.Bignum.Definitions.limb", "Lib.IntTypes.int_t", "Lib.IntTypes.lt_mask", "Lib.IntTypes.eq_mask", "Lib.LoopCombinators.unfold_repeat_gen", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Hacl.Spec.Bignum.Comparison.bn_lt_mask_f", "Lib.Buffer.as_seq", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "LowStar.Monotonic.Buffer.loc", "Lib.IntTypes.size_nat", "Lib.Buffer.loc", "Prims.int", "Lib.Sequence.index", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.Comparison open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions open Hacl.Bignum.Lib module S = Hacl.Spec.Bignum.Comparison module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Bignum comparison and test functions /// inline_for_extraction noextract val bn_is_odd: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_odd (as_seq h0 a)) let bn_is_odd #t len a = a.(0ul) &. uint #t 1 inline_for_extraction noextract val bn_eq_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b)) let bn_eq_mask #t len a b = push_frame (); let mask = create 1ul (ones t SEC) in let mask = Lib.ByteBuffer.buf_eq_mask a b len mask in pop_frame (); mask inline_for_extraction noextract val bn_is_zero_mask: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_zero_mask (as_seq h0 a)) let bn_is_zero_mask #t len b = push_frame (); let bn_zero = create len (uint #t 0) in let res = bn_eq_mask len b bn_zero in pop_frame (); res inline_for_extraction noextract val bn_lt_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b))
false
false
Hacl.Bignum.Comparison.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_lt_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b))
[]
Hacl.Bignum.Comparison.bn_lt_mask
{ "file_name": "code/bignum/Hacl.Bignum.Comparison.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t -> a: Hacl.Bignum.Definitions.lbignum t len -> b: Hacl.Bignum.Definitions.lbignum t len -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)
{ "end_col": 6, "end_line": 107, "start_col": 2, "start_line": 87 }
FStar.HyperStack.ST.Stack
val bn_eq_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Comparison", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_eq_mask #t len a b = push_frame (); let mask = create 1ul (ones t SEC) in let mask = Lib.ByteBuffer.buf_eq_mask a b len mask in pop_frame (); mask
val bn_eq_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b)) let bn_eq_mask #t len a b =
true
null
false
push_frame (); let mask = create 1ul (ones t SEC) in let mask = Lib.ByteBuffer.buf_eq_mask a b len mask in pop_frame (); mask
{ "checked_file": "Hacl.Bignum.Comparison.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Comparison.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.ByteBuffer.buf_eq_mask", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.ones", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.Comparison open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions open Hacl.Bignum.Lib module S = Hacl.Spec.Bignum.Comparison module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Bignum comparison and test functions /// inline_for_extraction noextract val bn_is_odd: #t:limb_t -> len:size_t{v len > 0} -> a:lbignum t len -> Stack (limb t) (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_is_odd (as_seq h0 a)) let bn_is_odd #t len a = a.(0ul) &. uint #t 1 inline_for_extraction noextract val bn_eq_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b))
false
false
Hacl.Bignum.Comparison.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_eq_mask: #t:limb_t -> len:size_t -> a:lbignum t len -> b:lbignum t len -> Stack (limb t) (requires fun h -> live h a /\ live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b))
[]
Hacl.Bignum.Comparison.bn_eq_mask
{ "file_name": "code/bignum/Hacl.Bignum.Comparison.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t -> a: Hacl.Bignum.Definitions.lbignum t len -> b: Hacl.Bignum.Definitions.lbignum t len -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)
{ "end_col": 6, "end_line": 54, "start_col": 2, "start_line": 50 }
Prims.Pure
val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4)
val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) =
false
null
false
let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint64", "Hacl.Spec.BignumQ.Definitions.qelem5", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple5", "FStar.Pervasives.Native.Mktuple5", "Prims.unit", "Hacl.Spec.BignumQ.Lemmas.lemma_choose_step", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Hat_Dot", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.u64" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y)
[]
Hacl.Spec.BignumQ.Mul.choose
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.IntTypes.uint64 -> x: Hacl.Spec.BignumQ.Definitions.qelem5 -> y: Hacl.Spec.BignumQ.Definitions.qelem5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 22, "end_line": 71, "start_col": 56, "start_line": 59 }
Prims.Tot
val mask56:x: uint64{v x == pow2 56 - 1}
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff
val mask56:x: uint64{v x == pow2 56 - 1} let mask56:x: uint64{v x == pow2 56 - 1} =
false
null
false
assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[ "total" ]
[ "Lib.IntTypes.u64", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.op_Subtraction", "Prims.pow2" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mask56:x: uint64{v x == pow2 56 - 1}
[]
Hacl.Spec.BignumQ.Mul.mask56
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC {Lib.IntTypes.v x == Prims.pow2 56 - 1}
{ "end_col": 22, "end_line": 17, "start_col": 2, "start_line": 16 }
Prims.Pure
val mod_264: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 t) % pow2 264)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = Lemmas.lemma_mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9); (t0, t1, t2, t3, t4 &. mask40)
val mod_264: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 t) % pow2 264) let mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) =
false
null
false
Lemmas.lemma_mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9); (t0, t1, t2, t3, t4 &. mask40)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Spec.BignumQ.Mul.mask40", "Prims.unit", "Hacl.Spec.BignumQ.Lemmas.lemma_mod_264", "FStar.Pervasives.Native.Mktuple10", "Hacl.Spec.BignumQ.Definitions.qelem5" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4) inline_for_extraction noextract val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24)) let div_2_24_step x y = let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z inline_for_extraction noextract val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248) let div_248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 248 == (x / pow2 224) / pow2 24 let z0 = div_2_24_step x4 x5 in let z1 = div_2_24_step x5 x6 in let z2 = div_2_24_step x6 x7 in let z3 = div_2_24_step x7 x8 in let z4 = div_2_24_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40)) let div_2_40_step x y = let y' = (y &. mask40) <<. 16ul in assert_norm (pow2 40 < pow2 64); mod_mask_lemma y 40ul; assert (v (mod_mask #U64 #SEC 40ul) == v mask40); assert (v y' == (v y % pow2 40) * pow2 16); let x' = x >>. 40ul in FStar.Math.Lemmas.pow2_minus 56 40; assert (v x' == v x / pow2 40); assert (v x' < pow2 16); let z = x' |. y' in logor_disjoint x' y' 16; z inline_for_extraction noextract val div_264: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 x) / pow2 264) let div_264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 264 == (x / pow2 224) / pow2 40 let z0 = div_2_40_step x4 x5 in let z1 = div_2_40_step x5 x6 in let z2 = div_2_40_step x6 x7 in let z3 = div_2_40_step x7 x8 in let z4 = div_2_40_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val mod_264: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 t) % pow2 264)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mod_264: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 t) % pow2 264)
[]
Hacl.Spec.BignumQ.Mul.mod_264
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 32, "end_line": 733, "start_col": 2, "start_line": 732 }
Prims.Tot
val mask40:x: uint64{v x == pow2 40 - 1}
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff
val mask40:x: uint64{v x == pow2 40 - 1} let mask40:x: uint64{v x == pow2 40 - 1} =
false
null
false
assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[ "total" ]
[ "Lib.IntTypes.u64", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.op_Subtraction", "Prims.pow2" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mask40:x: uint64{v x == pow2 40 - 1}
[]
Hacl.Spec.BignumQ.Mul.mask40
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC {Lib.IntTypes.v x == Prims.pow2 40 - 1}
{ "end_col": 18, "end_line": 23, "start_col": 2, "start_line": 22 }
Prims.Tot
val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q}
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4)
val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () =
false
null
false
let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[ "total" ]
[ "Prims.unit", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.uint64", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.nat", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Spec.Ed25519.q", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.v", "Lib.IntTypes.u64", "Hacl.Spec.BignumQ.Definitions.qelem5", "Prims.l_and", "Hacl.Spec.BignumQ.Definitions.qelem_fits5" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q}
[]
Hacl.Spec.BignumQ.Mul.make_m
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> m: Hacl.Spec.BignumQ.Definitions.qelem5 { Hacl.Spec.BignumQ.Definitions.qelem_fits5 m (1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.as_nat5 m == Spec.Ed25519.q }
{ "end_col": 22, "end_line": 35, "start_col": 15, "start_line": 28 }
Prims.Pure
val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d
val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d =
false
null
false
assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint128", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.U128", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Prims.op_Addition", "Lib.IntTypes.v", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116)
[]
Hacl.Spec.BignumQ.Mul.add4
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Lib.IntTypes.uint128 -> b: Lib.IntTypes.uint128 -> c: Lib.IntTypes.uint128 -> d: Lib.IntTypes.uint128 -> Prims.Pure Lib.IntTypes.uint128
{ "end_col": 18, "end_line": 300, "start_col": 2, "start_line": 293 }
Prims.Pure
val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b
val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b =
false
null
false
assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint128", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.U128", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Prims.op_Addition", "Lib.IntTypes.v", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116)
[]
Hacl.Spec.BignumQ.Mul.add2
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Lib.IntTypes.uint128 -> b: Lib.IntTypes.uint128 -> Prims.Pure Lib.IntTypes.uint128
{ "end_col": 8, "end_line": 266, "start_col": 2, "start_line": 263 }
Prims.Pure
val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b
val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b =
false
null
false
assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint128", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.U128", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Prims.op_Addition", "Lib.IntTypes.v", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117)
[]
Hacl.Spec.BignumQ.Mul.add_inner_carry
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Lib.IntTypes.uint128 -> b: Lib.IntTypes.uint128 -> Prims.Pure Lib.IntTypes.uint128
{ "end_col": 8, "end_line": 334, "start_col": 2, "start_line": 331 }
Prims.Pure
val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t
val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y =
false
null
false
let b = (x -. y) >>. 63ul in let lshift56 = (b <<. 56ul) in let t = ((b <<. 56ul) +! x) -! y in b, t
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple2", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Bang", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Less_Less_Dot", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.IntTypes.op_Subtraction_Dot", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56)
[]
Hacl.Spec.BignumQ.Mul.subm_step
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.IntTypes.uint64 -> y: Lib.IntTypes.uint64 -> Prims.Pure (Lib.IntTypes.uint64 * Lib.IntTypes.uint64)
{ "end_col": 6, "end_line": 90, "start_col": 19, "start_line": 82 }
Prims.Pure
val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry
val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x =
false
null
false
let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Lib.IntTypes.range_t", "Lib.IntTypes.mod_mask", "FStar.UInt32.__uint_to_t", "Hacl.Spec.BignumQ.Mul.mask56", "Lib.IntTypes.mod_mask_lemma", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Amp_Dot", "FStar.Math.Lemmas.pow2_minus", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t)
[]
Hacl.Spec.BignumQ.Mul.carry56
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.IntTypes.uint64 -> Prims.Pure (Lib.IntTypes.uint64 * Lib.IntTypes.uint64)
{ "end_col": 10, "end_line": 161, "start_col": 15, "start_line": 152 }
Prims.Pure
val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c
val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c =
false
null
false
assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint128", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.U128", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Prims.op_Addition", "Lib.IntTypes.v", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116)
[]
Hacl.Spec.BignumQ.Mul.add3
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Lib.IntTypes.uint128 -> b: Lib.IntTypes.uint128 -> c: Lib.IntTypes.uint128 -> Prims.Pure Lib.IntTypes.uint128
{ "end_col": 13, "end_line": 282, "start_col": 2, "start_line": 277 }
Prims.Pure
val div_264: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 x) / pow2 264)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let div_264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 264 == (x / pow2 224) / pow2 40 let z0 = div_2_40_step x4 x5 in let z1 = div_2_40_step x5 x6 in let z2 = div_2_40_step x6 x7 in let z3 = div_2_40_step x7 x8 in let z4 = div_2_40_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4)
val div_264: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 x) / pow2 264) let div_264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) =
false
null
false
let z0 = div_2_40_step x4 x5 in let z1 = div_2_40_step x5 x6 in let z2 = div_2_40_step x6 x7 in let z3 = div_2_40_step x7 x8 in let z4 = div_2_40_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Prims.unit", "Hacl.Spec.BignumQ.Lemmas.lemma_div264", "FStar.Pervasives.Native.Mktuple10", "Prims._assert", "Hacl.Spec.BignumQ.Definitions.qelem_fits5", "Prims.nat", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Spec.BignumQ.Mul.div_2_40_step", "Hacl.Spec.BignumQ.Definitions.qelem5" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4) inline_for_extraction noextract val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24)) let div_2_24_step x y = let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z inline_for_extraction noextract val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248) let div_248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 248 == (x / pow2 224) / pow2 24 let z0 = div_2_24_step x4 x5 in let z1 = div_2_24_step x5 x6 in let z2 = div_2_24_step x6 x7 in let z3 = div_2_24_step x7 x8 in let z4 = div_2_24_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40)) let div_2_40_step x y = let y' = (y &. mask40) <<. 16ul in assert_norm (pow2 40 < pow2 64); mod_mask_lemma y 40ul; assert (v (mod_mask #U64 #SEC 40ul) == v mask40); assert (v y' == (v y % pow2 40) * pow2 16); let x' = x >>. 40ul in FStar.Math.Lemmas.pow2_minus 56 40; assert (v x' == v x / pow2 40); assert (v x' < pow2 16); let z = x' |. y' in logor_disjoint x' y' 16; z inline_for_extraction noextract val div_264: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 x) / pow2 264)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val div_264: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 x) / pow2 264)
[]
Hacl.Spec.BignumQ.Mul.div_264
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 22, "end_line": 719, "start_col": 54, "start_line": 710 }
Prims.Pure
val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let div_248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 248 == (x / pow2 224) / pow2 24 let z0 = div_2_24_step x4 x5 in let z1 = div_2_24_step x5 x6 in let z2 = div_2_24_step x6 x7 in let z3 = div_2_24_step x7 x8 in let z4 = div_2_24_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4)
val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248) let div_248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) =
false
null
false
let z0 = div_2_24_step x4 x5 in let z1 = div_2_24_step x5 x6 in let z2 = div_2_24_step x6 x7 in let z3 = div_2_24_step x7 x8 in let z4 = div_2_24_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Prims.unit", "Hacl.Spec.BignumQ.Lemmas.lemma_div248", "FStar.Pervasives.Native.Mktuple10", "Prims._assert", "Hacl.Spec.BignumQ.Definitions.qelem_fits5", "Prims.nat", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Spec.BignumQ.Mul.div_2_24_step", "Hacl.Spec.BignumQ.Definitions.qelem5" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4) inline_for_extraction noextract val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24)) let div_2_24_step x y = let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z inline_for_extraction noextract val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248)
[]
Hacl.Spec.BignumQ.Mul.div_248
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 22, "end_line": 674, "start_col": 54, "start_line": 665 }
FStar.Pervasives.Lemma
val lemma_mult_distr_3 (a b c n: nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56))
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n
val lemma_mult_distr_3 (a b c n: nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) let lemma_mult_distr_3 (a b c n: nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) =
false
null
true
Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[ "lemma" ]
[ "Prims.nat", "FStar.Math.Lemmas.pow2_plus", "Prims.unit", "FStar.Math.Lemmas.distributivity_add_left", "Prims.pow2", "FStar.Math.Lemmas.distributivity_sub_left", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.int", "Prims.op_Subtraction", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56))
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_mult_distr_3 (a b c n: nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56))
[]
Hacl.Spec.BignumQ.Mul.lemma_mult_distr_3
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.nat -> b: Prims.nat -> c: Prims.nat -> n: Prims.nat -> FStar.Pervasives.Lemma (ensures (a + b - c * Prims.pow2 56) * Prims.pow2 n == a * Prims.pow2 n + b * Prims.pow2 n - c * Prims.pow2 (n + 56))
{ "end_col": 30, "end_line": 353, "start_col": 4, "start_line": 351 }
Prims.Pure
val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t
val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x =
false
null
false
let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint128", "FStar.Pervasives.Native.Mktuple2", "Lib.IntTypes.uint64", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.U128", "Lib.IntTypes.SEC", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Lib.IntTypes.U64", "Prims.op_Modulus", "FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1", "Lib.IntTypes.range_t", "Lib.IntTypes.mod_mask", "FStar.UInt32.__uint_to_t", "Hacl.Spec.BignumQ.Mul.mask56", "Lib.IntTypes.mod_mask_lemma", "Lib.IntTypes.to_u64", "FStar.Math.Lemmas.lemma_div_lt_nat", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56)
[]
Hacl.Spec.BignumQ.Mul.carry56_wide
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.IntTypes.uint128 -> Prims.Pure (Lib.IntTypes.uint128 * Lib.IntTypes.uint64)
{ "end_col": 10, "end_line": 209, "start_col": 20, "start_line": 198 }
Prims.Pure
val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e
val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e =
false
null
false
assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint128", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.U128", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Prims.op_Addition", "Lib.IntTypes.v", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116)
[]
Hacl.Spec.BignumQ.Mul.add5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Lib.IntTypes.uint128 -> b: Lib.IntTypes.uint128 -> c: Lib.IntTypes.uint128 -> d: Lib.IntTypes.uint128 -> e: Lib.IntTypes.uint128 -> Prims.Pure Lib.IntTypes.uint128
{ "end_col": 23, "end_line": 320, "start_col": 2, "start_line": 311 }
Prims.Pure
val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40))
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let div_2_40_step x y = let y' = (y &. mask40) <<. 16ul in assert_norm (pow2 40 < pow2 64); mod_mask_lemma y 40ul; assert (v (mod_mask #U64 #SEC 40ul) == v mask40); assert (v y' == (v y % pow2 40) * pow2 16); let x' = x >>. 40ul in FStar.Math.Lemmas.pow2_minus 56 40; assert (v x' == v x / pow2 40); assert (v x' < pow2 16); let z = x' |. y' in logor_disjoint x' y' 16; z
val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40)) let div_2_40_step x y =
false
null
false
let y' = (y &. mask40) <<. 16ul in assert_norm (pow2 40 < pow2 64); mod_mask_lemma y 40ul; assert (v (mod_mask #U64 #SEC 40ul) == v mask40); assert (v y' == (v y % pow2 40) * pow2 16); let x' = x >>. 40ul in FStar.Math.Lemmas.pow2_minus 56 40; assert (v x' == v x / pow2 40); assert (v x' < pow2 16); let z = x' |. y' in logor_disjoint x' y' 16; z
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint64", "Prims.unit", "Lib.IntTypes.logor_disjoint", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Bar_Dot", "Prims._assert", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Prims.pow2", "Prims.eq2", "Prims.int", "Prims.op_Division", "FStar.Math.Lemmas.pow2_minus", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.UInt32.__uint_to_t", "FStar.Mul.op_Star", "Prims.op_Modulus", "Lib.IntTypes.range_t", "Lib.IntTypes.mod_mask", "Hacl.Spec.BignumQ.Mul.mask40", "Lib.IntTypes.mod_mask_lemma", "FStar.Pervasives.assert_norm", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.op_Amp_Dot" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4) inline_for_extraction noextract val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24)) let div_2_24_step x y = let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z inline_for_extraction noextract val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248) let div_248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 248 == (x / pow2 224) / pow2 24 let z0 = div_2_24_step x4 x5 in let z1 = div_2_24_step x5 x6 in let z2 = div_2_24_step x6 x7 in let z3 = div_2_24_step x7 x8 in let z4 = div_2_24_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40))
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40))
[]
Hacl.Spec.BignumQ.Mul.div_2_40_step
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.IntTypes.uint64 -> y: Lib.IntTypes.uint64 -> Prims.Pure Lib.IntTypes.uint64
{ "end_col": 3, "end_line": 697, "start_col": 23, "start_line": 684 }
Prims.Pure
val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24))
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let div_2_24_step x y = let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z
val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24)) let div_2_24_step x y =
false
null
false
let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint64", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Addition", "Prims.op_Division", "Prims.pow2", "FStar.Mul.op_Star", "Prims.op_Modulus", "Lib.IntTypes.logor_disjoint", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Bar_Dot", "Prims.b2t", "Prims.op_LessThan", "FStar.Math.Lemmas.pow2_minus", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.u64", "Lib.IntTypes.mod_mask", "Lib.IntTypes.mod_mask_lemma", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.op_Subtraction", "Lib.IntTypes.op_Less_Less_Dot" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4) inline_for_extraction noextract val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24))
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24))
[]
Hacl.Spec.BignumQ.Mul.div_2_24_step
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.IntTypes.uint64 -> y: Lib.IntTypes.uint64 -> Prims.Pure Lib.IntTypes.uint64
{ "end_col": 3, "end_line": 652, "start_col": 23, "start_line": 638 }
Prims.Pure
val subm_last_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow2 40 /\ v y <= pow2 40) (ensures fun (b, t) -> v b <= 1 /\ v t < pow2 40 /\ v x - v y == v t - pow2 40 * v b)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subm_last_step x y = assert_norm (pow2 40 < pow2 63); let b = (x -. y) >>. 63ul in assert (if v x >= v y then v b == 0 else v b == 1); let t = ((b <<. 40ul) +! x) -! y in b, t
val subm_last_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow2 40 /\ v y <= pow2 40) (ensures fun (b, t) -> v b <= 1 /\ v t < pow2 40 /\ v x - v y == v t - pow2 40 * v b) let subm_last_step x y =
false
null
false
assert_norm (pow2 40 < pow2 63); let b = (x -. y) >>. 63ul in assert (if v x >= v y then v b == 0 else v b == 1); let t = ((b <<. 40ul) +! x) -! y in b, t
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple2", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Bang", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Less_Less_Dot", "FStar.UInt32.__uint_to_t", "Prims.unit", "Prims._assert", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.v", "Prims.eq2", "Prims.int", "Prims.bool", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.IntTypes.op_Subtraction_Dot", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4) inline_for_extraction noextract val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24)) let div_2_24_step x y = let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z inline_for_extraction noextract val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248) let div_248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 248 == (x / pow2 224) / pow2 24 let z0 = div_2_24_step x4 x5 in let z1 = div_2_24_step x5 x6 in let z2 = div_2_24_step x6 x7 in let z3 = div_2_24_step x7 x8 in let z4 = div_2_24_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40)) let div_2_40_step x y = let y' = (y &. mask40) <<. 16ul in assert_norm (pow2 40 < pow2 64); mod_mask_lemma y 40ul; assert (v (mod_mask #U64 #SEC 40ul) == v mask40); assert (v y' == (v y % pow2 40) * pow2 16); let x' = x >>. 40ul in FStar.Math.Lemmas.pow2_minus 56 40; assert (v x' == v x / pow2 40); assert (v x' < pow2 16); let z = x' |. y' in logor_disjoint x' y' 16; z inline_for_extraction noextract val div_264: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 x) / pow2 264) let div_264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 264 == (x / pow2 224) / pow2 40 let z0 = div_2_40_step x4 x5 in let z1 = div_2_40_step x5 x6 in let z2 = div_2_40_step x6 x7 in let z3 = div_2_40_step x7 x8 in let z4 = div_2_40_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val mod_264: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 t) % pow2 264) let mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = Lemmas.lemma_mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9); (t0, t1, t2, t3, t4 &. mask40) inline_for_extraction noextract val subm_last_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow2 40 /\ v y <= pow2 40) (ensures fun (b, t) -> v b <= 1 /\ v t < pow2 40 /\ v x - v y == v t - pow2 40 * v b)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subm_last_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow2 40 /\ v y <= pow2 40) (ensures fun (b, t) -> v b <= 1 /\ v t < pow2 40 /\ v x - v y == v t - pow2 40 * v b)
[]
Hacl.Spec.BignumQ.Mul.subm_last_step
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.IntTypes.uint64 -> y: Lib.IntTypes.uint64 -> Prims.Pure (Lib.IntTypes.uint64 * Lib.IntTypes.uint64)
{ "end_col": 6, "end_line": 748, "start_col": 2, "start_line": 744 }
Prims.Pure
val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b
val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b =
false
null
false
let lemma_smaller (a b: uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc ( < ) { v a * v b <: int; ( < ) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; ( < ) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; ( == ) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b: uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc ( <= ) { v a * v b <: int; ( <= ) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); ( <= ) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); ( == ) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Lib.IntTypes.uint64", "Lib.IntTypes.mul64_wide", "Prims.unit", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.b2t", "Hacl.Spec.BignumQ.Definitions.qelem_fits1", "Prims.squash", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U128", "Prims.op_Addition", "Prims.op_Subtraction", "Prims.pow2", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Calc.calc_finish", "Prims.int", "FStar.Mul.op_Star", "Prims.Cons", "FStar.Preorder.relation", "Prims.eq2", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.lemma_mult_le_left", "FStar.Math.Lemmas.lemma_mult_le_right", "FStar.Pervasives.assert_norm", "Prims.op_BarBar", "Prims.op_Equality", "Prims.bool", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Lib.IntTypes.uint128" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112)
[]
Hacl.Spec.BignumQ.Mul.mul64_wide_5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Lib.IntTypes.uint64 -> b: Lib.IntTypes.uint64 -> Prims.Pure Lib.IntTypes.uint128
{ "end_col": 16, "end_line": 252, "start_col": 22, "start_line": 220 }
Prims.Tot
val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q}
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4)
val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m =
false
null
false
let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[ "total" ]
[ "Prims.unit", "FStar.Pervasives.Native.Mktuple5", "Lib.IntTypes.uint64", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Prims.op_Division", "Prims.pow2", "Spec.Ed25519.q", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.range", "Lib.IntTypes.v", "Lib.IntTypes.u64", "Hacl.Spec.BignumQ.Definitions.qelem5", "Prims.l_and", "Hacl.Spec.BignumQ.Definitions.qelem_fits5", "Prims.nat" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q}
[]
Hacl.Spec.BignumQ.Mul.make_mu
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Prims.unit -> m: Hacl.Spec.BignumQ.Definitions.qelem5 { Hacl.Spec.BignumQ.Definitions.qelem_fits5 m (1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.as_nat5 m == Prims.pow2 512 / Spec.Ed25519.q }
{ "end_col": 22, "end_line": 47, "start_col": 15, "start_line": 40 }
Prims.Pure
val mul_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 256 /\ as_nat5 y < pow2 256) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % S.q)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let (r0, r1, r2, r3, r4, r5, r6, r7, r8, r9) = mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) in Lemmas.lemma_mul_lt (as_nat5 (x0, x1, x2, x3, x4)) (pow2 256) (as_nat5 (y0, y1, y2, y3, y4)) (pow2 256); assert_norm (pow2 256 * pow2 256 = pow2 512); let (o0, o1, o2, o3, o4) = barrett_reduction5 (r0, r1, r2, r3, r4, r5, r6, r7, r8, r9) in (o0, o1, o2, o3, o4)
val mul_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 256 /\ as_nat5 y < pow2 256) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % S.q) let mul_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) =
false
null
false
let r0, r1, r2, r3, r4, r5, r6, r7, r8, r9 = mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) in Lemmas.lemma_mul_lt (as_nat5 (x0, x1, x2, x3, x4)) (pow2 256) (as_nat5 (y0, y1, y2, y3, y4)) (pow2 256); assert_norm (pow2 256 * pow2 256 = pow2 512); let o0, o1, o2, o3, o4 = barrett_reduction5 (r0, r1, r2, r3, r4, r5, r6, r7, r8, r9) in (o0, o1, o2, o3, o4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Hacl.Spec.BignumQ.Mul.barrett_reduction5", "FStar.Pervasives.Native.Mktuple10", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "Prims.pow2", "Hacl.Spec.BignumQ.Lemmas.lemma_mul_lt", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Hacl.Spec.BignumQ.Mul.mul_5" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4) inline_for_extraction noextract val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24)) let div_2_24_step x y = let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z inline_for_extraction noextract val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248) let div_248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 248 == (x / pow2 224) / pow2 24 let z0 = div_2_24_step x4 x5 in let z1 = div_2_24_step x5 x6 in let z2 = div_2_24_step x6 x7 in let z3 = div_2_24_step x7 x8 in let z4 = div_2_24_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40)) let div_2_40_step x y = let y' = (y &. mask40) <<. 16ul in assert_norm (pow2 40 < pow2 64); mod_mask_lemma y 40ul; assert (v (mod_mask #U64 #SEC 40ul) == v mask40); assert (v y' == (v y % pow2 40) * pow2 16); let x' = x >>. 40ul in FStar.Math.Lemmas.pow2_minus 56 40; assert (v x' == v x / pow2 40); assert (v x' < pow2 16); let z = x' |. y' in logor_disjoint x' y' 16; z inline_for_extraction noextract val div_264: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 x) / pow2 264) let div_264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 264 == (x / pow2 224) / pow2 40 let z0 = div_2_40_step x4 x5 in let z1 = div_2_40_step x5 x6 in let z2 = div_2_40_step x6 x7 in let z3 = div_2_40_step x7 x8 in let z4 = div_2_40_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val mod_264: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 t) % pow2 264) let mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = Lemmas.lemma_mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9); (t0, t1, t2, t3, t4 &. mask40) inline_for_extraction noextract val subm_last_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow2 40 /\ v y <= pow2 40) (ensures fun (b, t) -> v b <= 1 /\ v t < pow2 40 /\ v x - v y == v t - pow2 40 * v b) let subm_last_step x y = assert_norm (pow2 40 < pow2 63); let b = (x -. y) >>. 63ul in assert (if v x >= v y then v b == 0 else v b == 1); let t = ((b <<. 40ul) +! x) -! y in b, t #push-options "--z3rlimit 400 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract val sub_mod_264: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ (if as_nat5 x >= as_nat5 y then as_nat5 z == as_nat5 x - as_nat5 y else as_nat5 z == as_nat5 x - as_nat5 y + pow2 264)) let sub_mod_264 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let (c1, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v c1 * pow56); let (c2, t1) = subm_step x1 (y1 +! c1) in assert (v x1 - v y1 - v c1 == v t1 - v c2 * pow56); let (c3, t2) = subm_step x2 (y2 +! c2) in assert (v x2 - v y2 - v c2 == v t2 - v c3 * pow56); let (c4, t3) = subm_step x3 (y3 +! c3) in assert (v x3 - v y3 - v c3 == v t3 - v c4 * pow56); Lemmas.lemma_as_nat_pow264_x4 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat_pow264_x4 (y0, y1, y2, y3, y4); let (c5, t4) = subm_last_step x4 (y4 +! c4) in assert (v x4 - v y4 - v c4 == v t4 - pow2 40 * v c5); assert ( if v c5 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= as_nat5 (y0, y1, y2, y3, y4) else as_nat5 (x0, x1, x2, x3, x4) < as_nat5 (y0, y1, y2, y3, y4)); assert_norm (pow2 40 < pow2 56); assert (qelem_fits5 (t0, t1, t2, t3, t4) (1, 1, 1, 1, 1)); assert (as_nat5 (t0, t1, t2, t3, t4) == v x0 - v y0 + v c1 * pow56 + (v x1 - v y1 - v c1 + v c2 * pow56) * pow56 + (v x2 - v y2 - v c2 + v c3 * pow56) * pow112 + (v x3 - v y3 - v c3 + v c4 * pow56) * pow168 + (v x4 - v y4 - v c4 + pow2 40 * v c5) * pow224); Lemmas.lemma_sub_mod_264_aux (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v c1) (v c2) (v c3) (v c4) (v c5); assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4) + v c5 * pow2 264); Lemmas.lemma_sub_mod_264 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4) c5; (t0, t1, t2, t3, t4) #pop-options // A = t, L = make_m() // b = 2^8, k = 32, mu = b^{2*k} / L = make_mu() inline_for_extraction noextract val barrett_reduction5: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 t < pow2 512) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 t) % S.q) let barrett_reduction5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = let (m0, m1, m2, m3, m4) = make_m () in let (mu0, mu1, mu2, mu3, mu4) = make_mu () in let (q0, q1, q2, q3, q4) = div_248 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in assert (as_nat5 (q0, q1, q2, q3, q4) == wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) / pow2 248); FStar.Math.Lemmas.lemma_div_lt_nat (wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)) 512 248; assert (as_nat5 (q0, q1, q2, q3, q4) < pow2 264); let (qmu0', qmu1', qmu2', qmu3', qmu4', qmu5', qmu6', qmu7', qmu8', qmu9') = mul_5 (q0, q1, q2, q3, q4) (mu0, mu1, mu2, mu3, mu4) in FStar.Math.Lemmas.lemma_mult_le_right (pow2 512 / S.q) (as_nat5 (q0, q1, q2, q3, q4)) (pow2 264); assert (wide_as_nat5 (qmu0', qmu1', qmu2', qmu3', qmu4', qmu5', qmu6', qmu7', qmu8', qmu9') <= pow2 512 / S.q * pow2 264); assert_norm (pow2 512 / S.q * pow2 264 < pow2 528); let (qdiv0, qdiv1, qdiv2, qdiv3, qdiv4) = div_264 (qmu0', qmu1', qmu2', qmu3', qmu4', qmu5', qmu6', qmu7', qmu8', qmu9') in //u = qdiv == (A / b^{k-1}) * mu / b^{k+1} == ((A / 2^248) * mu) / 2^264 let (r0, r1, r2, r3, r4) = mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in //r == A mod b^{k+1} == A mod 2^264 let (qmul0, qmul1, qmul2, qmul3, qmul4) = low_mul_5 (qdiv0, qdiv1, qdiv2, qdiv3, qdiv4) (m0, m1, m2, m3, m4) in //v == qmul == u * L mod b^{k+1} == u * L mod 2^264 let (s0, s1, s2, s3, s4) = sub_mod_264 (r0, r1, r2, r3, r4) (qmul0, qmul1, qmul2, qmul3, qmul4) in //u == s == (r - v) mod b^{k+1} == (r - v) mod 2^264 let (o0, o1, o2, o3, o4) = subm_conditional (s0, s1, s2, s3, s4) in Lemmas.lemma_barrett_reduce' (wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)); (o0, o1, o2, o3, o4) inline_for_extraction noextract val mul_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 256 /\ as_nat5 y < pow2 256) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % S.q)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 256 /\ as_nat5 y < pow2 256) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % S.q)
[]
Hacl.Spec.BignumQ.Mul.mul_modq5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem5 -> y: Hacl.Spec.BignumQ.Definitions.qelem5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 22, "end_line": 862, "start_col": 57, "start_line": 857 }
Prims.Pure
val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4)
val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) =
false
null
false
assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let t0, c0 = carry56 (x0 +! y0) in let t1, c1 = carry56 (x1 +! y1 +! c0) in let t2, c2 = carry56 (x2 +! y2 +! c1) in let t3, c3 = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let o0, o1, o2, o3, o4 = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Prims.unit", "Hacl.Spec.BignumQ.Lemmas.lemma_add_modq5", "Hacl.Spec.BignumQ.Mul.subm_conditional", "Prims._assert", "Prims.eq2", "Prims.int", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Prims.op_Addition", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Bang", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.BignumQ.Mul.carry56", "FStar.Pervasives.assert_norm", "Prims.op_Subtraction", "Hacl.Spec.BignumQ.Definitions.pow56", "Prims.pow2" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q)
[]
Hacl.Spec.BignumQ.Mul.add_modq5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem5 -> y: Hacl.Spec.BignumQ.Definitions.qelem5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 22, "end_line": 187, "start_col": 2, "start_line": 178 }
Prims.Pure
val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x))
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4)
val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) =
false
null
false
let y0, y1, y2, y3, y4 = make_m () in let b0, t0 = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let b1, t1 = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let b2, t2 = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let b3, t3 = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let b4, t4 = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert (as_nat5 (t0, t1, t2, t3, t4) - (v b4 * pow56) * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let z0, z1, z2, z3, z4 = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Prims.unit", "Prims._assert", "Prims.op_GreaterThanOrEqual", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Spec.Ed25519.q", "Prims.l_and", "Prims.eq2", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.nat", "Prims.bool", "Hacl.Spec.BignumQ.Mul.choose", "Hacl.Spec.BignumQ.Lemmas.lemma_as_nat5", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Hacl.Spec.BignumQ.Definitions.pow56", "Hacl.Spec.BignumQ.Definitions.pow224", "Hacl.Spec.BignumQ.Lemmas.lemma_subm_conditional", "FStar.Pervasives.Native.tuple2", "Lib.IntTypes.int_t", "Hacl.Spec.BignumQ.Mul.subm_step", "Lib.IntTypes.op_Plus_Bang", "Hacl.Spec.BignumQ.Definitions.qelem_fits5", "Hacl.Spec.BignumQ.Mul.make_m" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x))
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x))
[]
Hacl.Spec.BignumQ.Mul.subm_conditional
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 22, "end_line": 141, "start_col": 43, "start_line": 102 }
Prims.Pure
val sub_mod_264: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ (if as_nat5 x >= as_nat5 y then as_nat5 z == as_nat5 x - as_nat5 y else as_nat5 z == as_nat5 x - as_nat5 y + pow2 264))
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sub_mod_264 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let (c1, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v c1 * pow56); let (c2, t1) = subm_step x1 (y1 +! c1) in assert (v x1 - v y1 - v c1 == v t1 - v c2 * pow56); let (c3, t2) = subm_step x2 (y2 +! c2) in assert (v x2 - v y2 - v c2 == v t2 - v c3 * pow56); let (c4, t3) = subm_step x3 (y3 +! c3) in assert (v x3 - v y3 - v c3 == v t3 - v c4 * pow56); Lemmas.lemma_as_nat_pow264_x4 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat_pow264_x4 (y0, y1, y2, y3, y4); let (c5, t4) = subm_last_step x4 (y4 +! c4) in assert (v x4 - v y4 - v c4 == v t4 - pow2 40 * v c5); assert ( if v c5 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= as_nat5 (y0, y1, y2, y3, y4) else as_nat5 (x0, x1, x2, x3, x4) < as_nat5 (y0, y1, y2, y3, y4)); assert_norm (pow2 40 < pow2 56); assert (qelem_fits5 (t0, t1, t2, t3, t4) (1, 1, 1, 1, 1)); assert (as_nat5 (t0, t1, t2, t3, t4) == v x0 - v y0 + v c1 * pow56 + (v x1 - v y1 - v c1 + v c2 * pow56) * pow56 + (v x2 - v y2 - v c2 + v c3 * pow56) * pow112 + (v x3 - v y3 - v c3 + v c4 * pow56) * pow168 + (v x4 - v y4 - v c4 + pow2 40 * v c5) * pow224); Lemmas.lemma_sub_mod_264_aux (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v c1) (v c2) (v c3) (v c4) (v c5); assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4) + v c5 * pow2 264); Lemmas.lemma_sub_mod_264 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4) c5; (t0, t1, t2, t3, t4)
val sub_mod_264: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ (if as_nat5 x >= as_nat5 y then as_nat5 z == as_nat5 x - as_nat5 y else as_nat5 z == as_nat5 x - as_nat5 y + pow2 264)) let sub_mod_264 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) =
false
null
false
let c1, t0 = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v c1 * pow56); let c2, t1 = subm_step x1 (y1 +! c1) in assert (v x1 - v y1 - v c1 == v t1 - v c2 * pow56); let c3, t2 = subm_step x2 (y2 +! c2) in assert (v x2 - v y2 - v c2 == v t2 - v c3 * pow56); let c4, t3 = subm_step x3 (y3 +! c3) in assert (v x3 - v y3 - v c3 == v t3 - v c4 * pow56); Lemmas.lemma_as_nat_pow264_x4 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat_pow264_x4 (y0, y1, y2, y3, y4); let c5, t4 = subm_last_step x4 (y4 +! c4) in assert (v x4 - v y4 - v c4 == v t4 - pow2 40 * v c5); assert (if v c5 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= as_nat5 (y0, y1, y2, y3, y4) else as_nat5 (x0, x1, x2, x3, x4) < as_nat5 (y0, y1, y2, y3, y4)); assert_norm (pow2 40 < pow2 56); assert (qelem_fits5 (t0, t1, t2, t3, t4) (1, 1, 1, 1, 1)); assert (as_nat5 (t0, t1, t2, t3, t4) == v x0 - v y0 + v c1 * pow56 + (v x1 - v y1 - v c1 + v c2 * pow56) * pow56 + (v x2 - v y2 - v c2 + v c3 * pow56) * pow112 + (v x3 - v y3 - v c3 + v c4 * pow56) * pow168 + (v x4 - v y4 - v c4 + pow2 40 * v c5) * pow224); Lemmas.lemma_sub_mod_264_aux (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v c1) (v c2) (v c3) (v c4) (v c5); assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4) + v c5 * pow2 264); Lemmas.lemma_sub_mod_264 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4) c5; (t0, t1, t2, t3, t4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Prims.unit", "Hacl.Spec.BignumQ.Lemmas.lemma_sub_mod_264", "Prims._assert", "Prims.eq2", "Prims.int", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Prims.op_Addition", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.pow2", "Hacl.Spec.BignumQ.Lemmas.lemma_sub_mod_264_aux", "Hacl.Spec.BignumQ.Definitions.pow56", "Hacl.Spec.BignumQ.Definitions.pow112", "Hacl.Spec.BignumQ.Definitions.pow168", "Hacl.Spec.BignumQ.Definitions.pow224", "Hacl.Spec.BignumQ.Definitions.qelem_fits5", "Prims.nat", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "Prims.op_GreaterThanOrEqual", "Prims.bool", "FStar.Pervasives.Native.tuple2", "Lib.IntTypes.int_t", "Hacl.Spec.BignumQ.Mul.subm_last_step", "Lib.IntTypes.op_Plus_Bang", "Hacl.Spec.BignumQ.Lemmas.lemma_as_nat_pow264_x4", "Hacl.Spec.BignumQ.Mul.subm_step" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4) inline_for_extraction noextract val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24)) let div_2_24_step x y = let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z inline_for_extraction noextract val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248) let div_248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 248 == (x / pow2 224) / pow2 24 let z0 = div_2_24_step x4 x5 in let z1 = div_2_24_step x5 x6 in let z2 = div_2_24_step x6 x7 in let z3 = div_2_24_step x7 x8 in let z4 = div_2_24_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40)) let div_2_40_step x y = let y' = (y &. mask40) <<. 16ul in assert_norm (pow2 40 < pow2 64); mod_mask_lemma y 40ul; assert (v (mod_mask #U64 #SEC 40ul) == v mask40); assert (v y' == (v y % pow2 40) * pow2 16); let x' = x >>. 40ul in FStar.Math.Lemmas.pow2_minus 56 40; assert (v x' == v x / pow2 40); assert (v x' < pow2 16); let z = x' |. y' in logor_disjoint x' y' 16; z inline_for_extraction noextract val div_264: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 x) / pow2 264) let div_264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 264 == (x / pow2 224) / pow2 40 let z0 = div_2_40_step x4 x5 in let z1 = div_2_40_step x5 x6 in let z2 = div_2_40_step x6 x7 in let z3 = div_2_40_step x7 x8 in let z4 = div_2_40_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val mod_264: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 t) % pow2 264) let mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = Lemmas.lemma_mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9); (t0, t1, t2, t3, t4 &. mask40) inline_for_extraction noextract val subm_last_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow2 40 /\ v y <= pow2 40) (ensures fun (b, t) -> v b <= 1 /\ v t < pow2 40 /\ v x - v y == v t - pow2 40 * v b) let subm_last_step x y = assert_norm (pow2 40 < pow2 63); let b = (x -. y) >>. 63ul in assert (if v x >= v y then v b == 0 else v b == 1); let t = ((b <<. 40ul) +! x) -! y in b, t #push-options "--z3rlimit 400 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract val sub_mod_264: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ (if as_nat5 x >= as_nat5 y then as_nat5 z == as_nat5 x - as_nat5 y else as_nat5 z == as_nat5 x - as_nat5 y + pow2 264))
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 400, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sub_mod_264: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ (if as_nat5 x >= as_nat5 y then as_nat5 z == as_nat5 x - as_nat5 y else as_nat5 z == as_nat5 x - as_nat5 y + pow2 264))
[]
Hacl.Spec.BignumQ.Mul.sub_mod_264
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem5 -> y: Hacl.Spec.BignumQ.Definitions.qelem5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 22, "end_line": 798, "start_col": 59, "start_line": 766 }
Prims.Pure
val barrett_reduction5: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 t < pow2 512) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 t) % S.q)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let barrett_reduction5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = let (m0, m1, m2, m3, m4) = make_m () in let (mu0, mu1, mu2, mu3, mu4) = make_mu () in let (q0, q1, q2, q3, q4) = div_248 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in assert (as_nat5 (q0, q1, q2, q3, q4) == wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) / pow2 248); FStar.Math.Lemmas.lemma_div_lt_nat (wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)) 512 248; assert (as_nat5 (q0, q1, q2, q3, q4) < pow2 264); let (qmu0', qmu1', qmu2', qmu3', qmu4', qmu5', qmu6', qmu7', qmu8', qmu9') = mul_5 (q0, q1, q2, q3, q4) (mu0, mu1, mu2, mu3, mu4) in FStar.Math.Lemmas.lemma_mult_le_right (pow2 512 / S.q) (as_nat5 (q0, q1, q2, q3, q4)) (pow2 264); assert (wide_as_nat5 (qmu0', qmu1', qmu2', qmu3', qmu4', qmu5', qmu6', qmu7', qmu8', qmu9') <= pow2 512 / S.q * pow2 264); assert_norm (pow2 512 / S.q * pow2 264 < pow2 528); let (qdiv0, qdiv1, qdiv2, qdiv3, qdiv4) = div_264 (qmu0', qmu1', qmu2', qmu3', qmu4', qmu5', qmu6', qmu7', qmu8', qmu9') in //u = qdiv == (A / b^{k-1}) * mu / b^{k+1} == ((A / 2^248) * mu) / 2^264 let (r0, r1, r2, r3, r4) = mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in //r == A mod b^{k+1} == A mod 2^264 let (qmul0, qmul1, qmul2, qmul3, qmul4) = low_mul_5 (qdiv0, qdiv1, qdiv2, qdiv3, qdiv4) (m0, m1, m2, m3, m4) in //v == qmul == u * L mod b^{k+1} == u * L mod 2^264 let (s0, s1, s2, s3, s4) = sub_mod_264 (r0, r1, r2, r3, r4) (qmul0, qmul1, qmul2, qmul3, qmul4) in //u == s == (r - v) mod b^{k+1} == (r - v) mod 2^264 let (o0, o1, o2, o3, o4) = subm_conditional (s0, s1, s2, s3, s4) in Lemmas.lemma_barrett_reduce' (wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)); (o0, o1, o2, o3, o4)
val barrett_reduction5: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 t < pow2 512) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 t) % S.q) let barrett_reduction5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) =
false
null
false
let m0, m1, m2, m3, m4 = make_m () in let mu0, mu1, mu2, mu3, mu4 = make_mu () in let q0, q1, q2, q3, q4 = div_248 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in assert (as_nat5 (q0, q1, q2, q3, q4) == wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) / pow2 248); FStar.Math.Lemmas.lemma_div_lt_nat (wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)) 512 248; assert (as_nat5 (q0, q1, q2, q3, q4) < pow2 264); let qmu0', qmu1', qmu2', qmu3', qmu4', qmu5', qmu6', qmu7', qmu8', qmu9' = mul_5 (q0, q1, q2, q3, q4) (mu0, mu1, mu2, mu3, mu4) in FStar.Math.Lemmas.lemma_mult_le_right (pow2 512 / S.q) (as_nat5 (q0, q1, q2, q3, q4)) (pow2 264); assert (wide_as_nat5 (qmu0', qmu1', qmu2', qmu3', qmu4', qmu5', qmu6', qmu7', qmu8', qmu9') <= (pow2 512 / S.q) * pow2 264); assert_norm ((pow2 512 / S.q) * pow2 264 < pow2 528); let qdiv0, qdiv1, qdiv2, qdiv3, qdiv4 = div_264 (qmu0', qmu1', qmu2', qmu3', qmu4', qmu5', qmu6', qmu7', qmu8', qmu9') in let r0, r1, r2, r3, r4 = mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) in let qmul0, qmul1, qmul2, qmul3, qmul4 = low_mul_5 (qdiv0, qdiv1, qdiv2, qdiv3, qdiv4) (m0, m1, m2, m3, m4) in let s0, s1, s2, s3, s4 = sub_mod_264 (r0, r1, r2, r3, r4) (qmul0, qmul1, qmul2, qmul3, qmul4) in let o0, o1, o2, o3, o4 = subm_conditional (s0, s1, s2, s3, s4) in Lemmas.lemma_barrett_reduce' (wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)); (o0, o1, o2, o3, o4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Prims.unit", "Hacl.Spec.BignumQ.Lemmas.lemma_barrett_reduce'", "Hacl.Spec.BignumQ.Definitions.wide_as_nat5", "FStar.Pervasives.Native.Mktuple10", "Hacl.Spec.BignumQ.Definitions.qelem5", "Hacl.Spec.BignumQ.Mul.subm_conditional", "Hacl.Spec.BignumQ.Mul.sub_mod_264", "Hacl.Spec.BignumQ.Mul.low_mul_5", "Hacl.Spec.BignumQ.Mul.mod_264", "Hacl.Spec.BignumQ.Mul.div_264", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Prims.op_Division", "Prims.pow2", "Spec.Ed25519.q", "Prims._assert", "Prims.op_LessThanOrEqual", "FStar.Math.Lemmas.lemma_mult_le_right", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Hacl.Spec.BignumQ.Mul.mul_5", "FStar.Math.Lemmas.lemma_div_lt_nat", "Prims.eq2", "Prims.int", "Hacl.Spec.BignumQ.Mul.div_248", "Prims.l_and", "Hacl.Spec.BignumQ.Definitions.qelem_fits5", "Prims.nat", "Hacl.Spec.BignumQ.Mul.make_mu", "Hacl.Spec.BignumQ.Mul.make_m" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4) inline_for_extraction noextract val div_2_24_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56 /\ v y < pow56) (ensures fun r -> v r < pow56 /\ v r == v x / pow2 24 + pow2 32 * (v y % pow2 24)) let div_2_24_step x y = let y' = (y &. u64 0xffffff) <<. 32ul in assert_norm (pow2 24 - 1 = 0xffffff); assert_norm (pow2 24 < pow2 64); mod_mask_lemma y 24ul; assert (v (mod_mask #U64 #SEC 24ul) == 0xffffff); assert (v (y &. u64 0xffffff) == v y % pow2 24); assert (v y' == (v y % pow2 24) * pow2 32); let x' = x >>. 24ul in FStar.Math.Lemmas.pow2_minus 56 24; assert (v x' < pow2 32); let z = x' |. y' in logor_disjoint x' y' 32; assert (v z == v x / pow2 24 + pow2 32 * (v y % pow2 24)); z inline_for_extraction noextract val div_248: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 x) / pow2 248) let div_248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 248 == (x / pow2 224) / pow2 24 let z0 = div_2_24_step x4 x5 in let z1 = div_2_24_step x5 x6 in let z2 = div_2_24_step x6 x7 in let z3 = div_2_24_step x7 x8 in let z4 = div_2_24_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div248 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val div_2_40_step: x:uint64 -> y:uint64 -> Pure uint64 (requires v x < pow56) (ensures fun z -> v z < pow56 /\ v z == v x / pow2 40 + pow2 16 * (v y % pow2 40)) let div_2_40_step x y = let y' = (y &. mask40) <<. 16ul in assert_norm (pow2 40 < pow2 64); mod_mask_lemma y 40ul; assert (v (mod_mask #U64 #SEC 40ul) == v mask40); assert (v y' == (v y % pow2 40) * pow2 16); let x' = x >>. 40ul in FStar.Math.Lemmas.pow2_minus 56 40; assert (v x' == v x / pow2 40); assert (v x' < pow2 16); let z = x' |. y' in logor_disjoint x' y' 16; z inline_for_extraction noextract val div_264: x:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 x) / pow2 264) let div_264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = // x / pow2 264 == (x / pow2 224) / pow2 40 let z0 = div_2_40_step x4 x5 in let z1 = div_2_40_step x5 x6 in let z2 = div_2_40_step x6 x7 in let z3 = div_2_40_step x7 x8 in let z4 = div_2_40_step x8 x9 in assert (qelem_fits5 (z0, z1, z2, z3, z4) (1, 1, 1, 1, 1)); Lemmas.lemma_div264 (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); (z0, z1, z2, z3, z4) inline_for_extraction noextract val mod_264: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (wide_as_nat5 t) % pow2 264) let mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = Lemmas.lemma_mod_264 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9); (t0, t1, t2, t3, t4 &. mask40) inline_for_extraction noextract val subm_last_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow2 40 /\ v y <= pow2 40) (ensures fun (b, t) -> v b <= 1 /\ v t < pow2 40 /\ v x - v y == v t - pow2 40 * v b) let subm_last_step x y = assert_norm (pow2 40 < pow2 63); let b = (x -. y) >>. 63ul in assert (if v x >= v y then v b == 0 else v b == 1); let t = ((b <<. 40ul) +! x) -! y in b, t #push-options "--z3rlimit 400 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract val sub_mod_264: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ (if as_nat5 x >= as_nat5 y then as_nat5 z == as_nat5 x - as_nat5 y else as_nat5 z == as_nat5 x - as_nat5 y + pow2 264)) let sub_mod_264 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let (c1, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v c1 * pow56); let (c2, t1) = subm_step x1 (y1 +! c1) in assert (v x1 - v y1 - v c1 == v t1 - v c2 * pow56); let (c3, t2) = subm_step x2 (y2 +! c2) in assert (v x2 - v y2 - v c2 == v t2 - v c3 * pow56); let (c4, t3) = subm_step x3 (y3 +! c3) in assert (v x3 - v y3 - v c3 == v t3 - v c4 * pow56); Lemmas.lemma_as_nat_pow264_x4 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat_pow264_x4 (y0, y1, y2, y3, y4); let (c5, t4) = subm_last_step x4 (y4 +! c4) in assert (v x4 - v y4 - v c4 == v t4 - pow2 40 * v c5); assert ( if v c5 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= as_nat5 (y0, y1, y2, y3, y4) else as_nat5 (x0, x1, x2, x3, x4) < as_nat5 (y0, y1, y2, y3, y4)); assert_norm (pow2 40 < pow2 56); assert (qelem_fits5 (t0, t1, t2, t3, t4) (1, 1, 1, 1, 1)); assert (as_nat5 (t0, t1, t2, t3, t4) == v x0 - v y0 + v c1 * pow56 + (v x1 - v y1 - v c1 + v c2 * pow56) * pow56 + (v x2 - v y2 - v c2 + v c3 * pow56) * pow112 + (v x3 - v y3 - v c3 + v c4 * pow56) * pow168 + (v x4 - v y4 - v c4 + pow2 40 * v c5) * pow224); Lemmas.lemma_sub_mod_264_aux (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v c1) (v c2) (v c3) (v c4) (v c5); assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4) + v c5 * pow2 264); Lemmas.lemma_sub_mod_264 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4) c5; (t0, t1, t2, t3, t4) #pop-options // A = t, L = make_m() // b = 2^8, k = 32, mu = b^{2*k} / L = make_mu() inline_for_extraction noextract val barrett_reduction5: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 t < pow2 512) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 t) % S.q)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val barrett_reduction5: t:qelem_wide5 -> Pure qelem5 (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 t < pow2 512) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (wide_as_nat5 t) % S.q)
[]
Hacl.Spec.BignumQ.Mul.barrett_reduction5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 22, "end_line": 843, "start_col": 65, "start_line": 814 }
Prims.Pure
val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.BignumQ.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let (c0, t0) = carry56_wide xy00 in let (c1, t1) = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let (c2, t2) = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let (c3, t3) = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc (==) { as_nat5 (t0, t1, t2, t3, t4) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; (==) { } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; (==) { logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64 } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4)
val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264) let low_mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) =
false
null
false
let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy40 = mul64_wide_5 x4 y0 in assert_norm (pow2 112 < pow2 117); let c0, t0 = carry56_wide xy00 in let c1, t1 = carry56_wide (add_inner_carry (add2 xy01 xy10) c0) in let c2, t2 = carry56_wide (add_inner_carry (add3 xy02 xy11 xy20) c1) in let c3, t3 = carry56_wide (add_inner_carry (add4 xy03 xy12 xy21 xy30) c2) in let t4 = to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3) &. mask40 in calc ( == ) { as_nat5 (t0, t1, t2, t3, t4) <: int; ( == ) { () } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224; ( == ) { () } v xy00 - v c0 * pow2 56 + (v xy01 + v xy10 + v c0 - v c1 * pow2 56) * pow56 + (v xy02 + v xy11 + v xy20 + v c1 - v c2 * pow56) * pow112 + (v xy03 + v xy12 + v xy21 + v xy30 + v c2 - v c3 * pow56) * pow168 + v t4 * pow224; ( == ) { (logand_mask (to_u64 (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) mask40 40; Math.Lemmas.pow2_modulo_modulo_lemma_1 (v (add_inner_carry (add5 xy04 xy13 xy22 xy31 xy40) c3)) 40 64) } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0 - v c3 * pow56) * pow168 + ((v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0 + v c3) % pow2 40) * pow224; }; Lemmas.lemma_mul_5_low_264 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4); (t0, t1, t2, t3, t4)
{ "checked_file": "Hacl.Spec.BignumQ.Mul.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Lemmas.fst.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Mul.fst" }
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.uint128", "Lib.IntTypes.uint64", "FStar.Pervasives.Native.Mktuple5", "Prims.unit", "Hacl.Spec.BignumQ.Lemmas.lemma_mul_5_low_264", "Lib.IntTypes.v", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Prims.op_Addition", "FStar.Mul.op_Star", "Hacl.Spec.BignumQ.Definitions.pow56", "Hacl.Spec.BignumQ.Definitions.pow112", "Prims.op_Subtraction", "Lib.IntTypes.U128", "Hacl.Spec.BignumQ.Definitions.pow168", "Prims.op_Modulus", "Prims.pow2", "Hacl.Spec.BignumQ.Definitions.pow224", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1", "Hacl.Spec.BignumQ.Mul.add_inner_carry", "Hacl.Spec.BignumQ.Mul.add5", "Lib.IntTypes.logand_mask", "Lib.IntTypes.to_u64", "Hacl.Spec.BignumQ.Mul.mask40", "Lib.IntTypes.op_Amp_Dot", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.BignumQ.Mul.carry56_wide", "Hacl.Spec.BignumQ.Mul.add4", "Hacl.Spec.BignumQ.Mul.add3", "Hacl.Spec.BignumQ.Mul.add2", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.BignumQ.Mul.mul64_wide_5" ]
[]
module Hacl.Spec.BignumQ.Mul open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 module Lemmas = Hacl.Spec.BignumQ.Lemmas include Hacl.Spec.BignumQ.Definitions #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract let mask56 : x:uint64{v x == pow2 56 - 1} = assert_norm (pow2 56 - 1 == 0xffffffffffffff); u64 0xffffffffffffff inline_for_extraction noextract let mask40 : x:uint64{v x == pow2 40 - 1} = assert_norm (pow2 40 - 1 == 0xffffffffff); u64 0xffffffffff inline_for_extraction noextract val make_m: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == S.q} let make_m () = let m0 = u64 0x12631a5cf5d3ed in let m1 = u64 0xf9dea2f79cd658 in let m2 = u64 0x000000000014de in let m3 = u64 0x00000000000000 in let m4 = u64 0x00000010000000 in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val make_mu: unit -> m:qelem5{qelem_fits5 m (1, 1, 1, 1, 1) /\ as_nat5 m == pow2 512 / S.q} let make_mu m = let m0 = u64 0x9ce5a30a2c131b in let m1 = u64 0x215d086329a7ed in let m2 = u64 0xffffffffeb2106 in let m3 = u64 0xffffffffffffff in let m4 = u64 0x00000fffffffff in assert_norm (as_nat5 (m0, m1, m2, m3, m4) == pow2 512 / S.q); (m0, m1, m2, m3, m4) inline_for_extraction noextract val choose: b:uint64 -> x:qelem5 -> y:qelem5 -> Pure qelem5 (requires v b == 0 \/ v b == 1) (ensures fun z -> if v b = 1 then z == x else z == y) let choose b (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let mask = b -. u64 1 in let z0 = x0 ^. (mask &. (x0 ^. y0)) in Lemmas.lemma_choose_step b x0 y0; let z1 = x1 ^. (mask &. (x1 ^. y1)) in Lemmas.lemma_choose_step b x1 y1; let z2 = x2 ^. (mask &. (x2 ^. y2)) in Lemmas.lemma_choose_step b x2 y2; let z3 = x3 ^. (mask &. (x3 ^. y3)) in Lemmas.lemma_choose_step b x3 y3; let z4 = x4 ^. (mask &. (x4 ^. y4)) in Lemmas.lemma_choose_step b x4 y4; (z0, z1, z2, z3, z4) inline_for_extraction noextract val subm_step: x:uint64 -> y:uint64 -> Pure (uint64 & uint64) (requires v x < pow56 /\ v y <= pow56) (ensures fun (b, t) -> v b <= 1 /\ qelem_fits1 t 1 /\ v x - v y == v t - v b * pow56) let subm_step x y = let b = (x -. y) >>. 63ul in //assert (if v x >= v y then v b == 0 else v b == 1); let lshift56 = (b <<. 56ul) in //assert (if v x >= v y then v lshift56 == 0 else v lshift56 == pow56); //assert (v lshift56 == v b * pow56); //assert (v ((b <<. 56ul) +! x) == v b * pow56 + v x); let t = ((b <<. 56ul) +! x) -! y in b, t inline_for_extraction noextract val subm_conditional: x:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ (if as_nat5 x >= S.q then as_nat5 r == as_nat5 x - S.q else as_nat5 r == as_nat5 x)) let subm_conditional (x0, x1, x2, x3, x4) = let (y0, y1, y2, y3, y4) = make_m () in let (b0, t0) = subm_step x0 y0 in assert (v x0 - v y0 == v t0 - v b0 * pow56); let (b1, t1) = subm_step x1 (y1 +! b0) in assert (v x1 - v y1 - v b0 == v t1 - v b1 * pow56); let (b2, t2) = subm_step x2 (y2 +! b1) in assert (v x2 - v y2 - v b1 == v t2 - v b2 * pow56); let (b3, t3) = subm_step x3 (y3 +! b2) in assert (v x3 - v y3 - v b2 == v t3 - v b3 * pow56); let (b4, t4) = subm_step x4 (y4 +! b3) in assert (v x4 - v y4 - v b3 == v t4 - v b4 * pow56); Lemmas.lemma_subm_conditional (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) (v b0) (v b1) (v b2) (v b3) (v b4); assert ( as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow56 * pow224 == as_nat5 (x0, x1, x2, x3, x4) - as_nat5 (y0, y1, y2, y3, y4)); //assert_norm (pow56 * pow224 = pow2 280); //assert (as_nat5 (t0, t1, t2, t3, t4) - v b4 * pow2 280 == as_nat5 (x0, x1, x2, x3, x4) - S.q); Lemmas.lemma_as_nat5 (x0, x1, x2, x3, x4); Lemmas.lemma_as_nat5 (t0, t1, t2, t3, t4); //assert (if v b4 = 0 then as_nat5 (x0, x1, x2, x3, x4) >= S.q else as_nat5 (x0, x1, x2, x3, x4) < S.q); assert (if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 else v b4 == 1); let (z0, z1, z2, z3, z4) = choose b4 (x0, x1, x2, x3, x4) (t0, t1, t2, t3, t4) in assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); assert ( if as_nat5 (x0, x1, x2, x3, x4) >= S.q then v b4 == 0 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (t0, t1, t2, t3, t4) else v b4 == 1 /\ as_nat5 (z0, z1, z2, z3, z4) == as_nat5 (x0, x1, x2, x3, x4)); (z0, z1, z2, z3, z4) inline_for_extraction noextract val carry56: x:uint64 -> Pure (uint64 & uint64) (requires v x <= pow2 57) (ensures fun (t, c) -> v t < pow56 /\ v c <= 2 /\ v x == v c * pow56 + v t) let carry56 x = let carry = x >>. 56ul in FStar.Math.Lemmas.pow2_minus 57 56; let t = x &. mask56 in assert_norm (pow2 56 < pow2 64); mod_mask_lemma x 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); t, carry inline_for_extraction noextract val add_modq5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q) (ensures fun z -> qelem_fits5 z (1, 1, 1, 1, 1) /\ as_nat5 z == (as_nat5 x + as_nat5 y) % S.q) let add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = assert_norm (pow56 - 1 + pow56 - 1 == pow2 57 - 2); let (t0, c0) = carry56 (x0 +! y0) in let (t1, c1) = carry56 (x1 +! y1 +! c0) in let (t2, c2) = carry56 (x2 +! y2 +! c1) in let (t3, c3) = carry56 (x3 +! y3 +! c2) in let t4 = x4 +! y4 +! c3 in assert (as_nat5 (t0, t1, t2, t3, t4) == as_nat5 (x0, x1, x2, x3, x4) + as_nat5 (y0, y1, y2, y3, y4)); let (o0, o1, o2, o3, o4) = subm_conditional (t0, t1, t2, t3, t4) in Lemmas.lemma_add_modq5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) (t0, t1, t2, t3, t4); (o0, o1, o2, o3, o4) inline_for_extraction noextract val carry56_wide: x:uint128 -> Pure (uint128 & uint64) (requires v x < pow2 117) (ensures fun (c, t) -> v t < pow56 /\ v c < pow2 61 /\ v x - v c * pow56 == v t /\ v c == v x / pow56) let carry56_wide x = let carry = x >>. 56ul in let t = to_u64 x &. mask56 in assert_norm (pow2 56 < pow2 64); Math.Lemmas.lemma_div_lt_nat (v x) 117 56; mod_mask_lemma (to_u64 x) 56ul; assert (v (mod_mask #U64 #SEC 56ul) == v mask56); assert (v t == (v x % pow2 64) % pow2 56); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v x) 56 64; assert (v t == v x % pow2 56); assert (v x == v carry * pow2 56 + v t); carry, t inline_for_extraction noextract val mul64_wide_5: (a:uint64) -> (b:uint64) -> Pure uint128 (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures fun z -> v z == v a * v b /\ v z <= pow2 112 - pow2 57 + 1 /\ v z < pow2 112) let mul64_wide_5 a b = let lemma_smaller (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) < pow2 112) = if v a = 0 || v b = 0 then () else calc (<) { v a * v b <: int; (<) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56) } v a * pow2 56; (<) { Math.Lemmas.lemma_mult_le_right (pow2 56) (v a) (pow2 56) } pow2 56 * pow2 56; (==) { assert_norm (pow2 56 * pow2 56 == pow2 112) } pow2 112; } in let lemma_le (a b:uint64) : Lemma (requires qelem_fits1 a 1 /\ qelem_fits1 b 1) (ensures v (mul64_wide a b) <= pow2 112 - pow2 57 + 1) = if v a = 0 || v b = 0 then () else assert_norm (pow2 112 - pow2 57 + 1 >= 0); calc (<=) { v a * v b <: int; (<=) { Math.Lemmas.lemma_mult_le_left (v a) (v b) (pow2 56 - 1) } v a * (pow2 56 - 1); (<=) { Math.Lemmas.lemma_mult_le_right (pow2 56 - 1) (v a) (pow2 56 - 1) } (pow2 56 - 1) * (pow2 56 - 1); (==) { assert_norm ((pow2 56 - 1) * (pow2 56 - 1) == pow2 112 - pow2 57 + 1) } pow2 112 - pow2 57 + 1; } in lemma_le a b; lemma_smaller a b; mul64_wide a b inline_for_extraction noextract val add2: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112) (ensures fun z -> v z == v a + v b /\ v z <= pow2 116) let add2 a b = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val add3: (a:uint128) -> (b:uint128) -> (c:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 ) (ensures fun z -> v z == v a + v b + v c /\ v z <= pow2 116) let add3 a b c = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); a +. b +. c inline_for_extraction noextract val add4: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d /\ v z <= pow2 116) let add4 a b c d = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); a +. b +. c +. d inline_for_extraction noextract val add5: (a:uint128) -> (b:uint128) -> (c:uint128) -> (d:uint128) -> (e:uint128) -> Pure uint128 (requires v a < pow2 112 /\ v b < pow2 112 /\ v c < pow2 112 /\ v d < pow2 112 /\ v e < pow2 112) (ensures fun z -> v z == v a + v b + v c + v d + v e/\ v z <= pow2 116) let add5 a b c d e = assert_norm (pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 < pow2 128); assert_norm (pow2 112 + pow2 112 + pow2 112 + pow2 112 + pow2 112 <= pow2 116); Math.Lemmas.small_mod (v a + v b) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d) (pow2 128); Math.Lemmas.small_mod (v a + v b + v c + v d + v e) (pow2 128); a +. b +. c +. d +. e inline_for_extraction noextract val add_inner_carry: (a:uint128) -> (b:uint128) -> Pure uint128 (requires v a <= pow2 116 /\ v b < pow2 61) (ensures fun z -> v z == v a + v b /\ v z < pow2 117) let add_inner_carry a b = assert_norm (pow2 116 + pow2 61 < pow2 128); assert_norm (pow2 116 + pow2 61 < pow2 117); Math.Lemmas.small_mod (v a + v b) (pow2 128); a +. b inline_for_extraction noextract val mul_5: x:qelem5 -> y:qelem5 -> Pure qelem_wide5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_wide_fits5 r (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 r == as_nat5 x * as_nat5 y) let lemma_mult_distr_3 (a b c:nat) (n:nat) : Lemma ((a + b - c * pow2 56) * pow2 n == a * pow2 n + b * pow2 n - c * pow2 (n + 56)) = Math.Lemmas.distributivity_sub_left (a + b) (c * pow2 56) (pow2 n); Math.Lemmas.distributivity_add_left a b (pow2 n); Math.Lemmas.pow2_plus 56 n #set-options "--z3rlimit 300" let mul_5 (x0, x1, x2, x3, x4) (y0, y1, y2, y3, y4) = let xy00 = mul64_wide_5 x0 y0 in let xy01 = mul64_wide_5 x0 y1 in let xy02 = mul64_wide_5 x0 y2 in let xy03 = mul64_wide_5 x0 y3 in let xy04 = mul64_wide_5 x0 y4 in let xy10 = mul64_wide_5 x1 y0 in let xy11 = mul64_wide_5 x1 y1 in let xy12 = mul64_wide_5 x1 y2 in let xy13 = mul64_wide_5 x1 y3 in let xy14 = mul64_wide_5 x1 y4 in let xy20 = mul64_wide_5 x2 y0 in let xy21 = mul64_wide_5 x2 y1 in let xy22 = mul64_wide_5 x2 y2 in let xy23 = mul64_wide_5 x2 y3 in let xy24 = mul64_wide_5 x2 y4 in let xy30 = mul64_wide_5 x3 y0 in let xy31 = mul64_wide_5 x3 y1 in let xy32 = mul64_wide_5 x3 y2 in let xy33 = mul64_wide_5 x3 y3 in let xy34 = mul64_wide_5 x3 y4 in let xy40 = mul64_wide_5 x4 y0 in let xy41 = mul64_wide_5 x4 y1 in let xy42 = mul64_wide_5 x4 y2 in let xy43 = mul64_wide_5 x4 y3 in let xy44 = mul64_wide_5 x4 y4 in let z0 = xy00 in // < pow2 112 let z1 = add2 xy01 xy10 in // < pow2 113 let z2 = add3 xy02 xy11 xy20 in // < pow2 114 let z3 = add4 xy03 xy12 xy21 xy30 in // < pow2 115 let z4 = add5 xy04 xy13 xy22 xy31 xy40 in // < pow2 116 let z5 = add4 xy14 xy23 xy32 xy41 in let z6 = add3 xy24 xy33 xy42 in let z7 = add2 xy34 xy43 in let z8 = xy44 in //(z0, z1, z2, z3, z4, z5, z6, z7, z8) assert_norm (pow2 112 < pow2 117); assert_norm (pow2 112 <= pow2 116); let (c0, t0) = carry56_wide z0 in let (c1, t1) = carry56_wide (add_inner_carry z1 c0) in let (c2, t2) = carry56_wide (add_inner_carry z2 c1) in let (c3, t3) = carry56_wide (add_inner_carry z3 c2) in let (c4, t4) = carry56_wide (add_inner_carry z4 c3) in let (c5, t5) = carry56_wide (add_inner_carry z5 c4) in let (c6, t6) = carry56_wide (add_inner_carry z6 c5) in let (c7, t7) = carry56_wide (add_inner_carry z7 c6) in let (c8, t8) = carry56_wide (add_inner_carry z8 c7) in let t9 = to_u64 c8 in let lemma_t9_fits () : Lemma (v t9 < pow2 56) = // This proof was built from the bottom. We have as a constraint that v c8 has to be < pow2 112 to satisfy the postcondition. // We compute each time the maximal value such that this postcondition is satisfied calc (<) { v c0; (<) { Math.Lemmas.lemma_div_lt_nat (v z0) 112 56 } pow2 56; }; calc (<) { v c1; (<) { assert_norm (2*(pow2 112 - pow2 57 + 1) + pow2 56 <= pow2 113); Math.Lemmas.lemma_div_lt_nat (v z1 + v c0) 113 56 } pow2 57; }; calc (<) { v c2; (<) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 57 <= pow2 114); Math.Lemmas.lemma_div_lt_nat (v z2 + v c1) 114 56 } pow2 58; }; calc (<=) { v c3; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + pow2 58 <= 31153781151208965410895007785680895); assert_norm (31153781151208965410895007785680895 / pow56 == 432345564227567610); Math.Lemmas.lemma_div_le (v z3 + v c2) 31153781151208965410895007785680895 (pow2 56) } 432345564227567610; }; calc (<=) { v c4; (<=) { assert_norm (5*(pow2 112 - pow2 57 + 1) + 432345564227567610 <= 25961484292674137854422105494388735); // (pow2 59 - 2) * pow56 assert_norm (25961484292674137854422105494388735 / pow56 == 360287970189639675); Math.Lemmas.lemma_div_le (v z4 + v c3) 25961484292674137854422105494388735 (pow2 56) } 360287970189639675; }; calc (<=) { v c5; (<=) { assert_norm (4*(pow2 112 - pow2 57 + 1) + 360287970189639675 <= 20769187434139310297949203203096575); Math.Lemmas.lemma_div_le (v z5 + v c4) 20769187434139310297949203203096575 (pow2 56); assert_norm (20769187434139310297949203203096575 / pow2 56 == pow2 58 - 4) } pow2 58 - 4; }; calc (<=) { v c6; (<=) { assert_norm (3*(pow2 112 - pow2 57 + 1) + pow2 58 - 4 <= 15576890575604482741476300911804415); Math.Lemmas.lemma_div_le (v z6 + v c5) 15576890575604482741476300911804415 (pow2 56); assert_norm (15576890575604482741476300911804415 / pow2 56 == 216172782113783805) } 216172782113783805; }; calc (<=) { v c7; (<=) { assert_norm (2*(pow2 112 - pow2 57 + 1) + 216172782113783805 <= 10384593717069655185003398620512255); // (pow2 57 - 1) * pow2 56 - 1 Math.Lemmas.lemma_div_le (v z7 + v c6) 10384593717069655185003398620512255 (pow2 56); assert_norm (10384593717069655185003398620512255 / pow2 56 == pow2 57 - 2) } pow2 57 - 2; }; calc (<) { v c8; (<) { Math.Lemmas.lemma_div_lt_nat (v z8 + v c7) 112 56 } pow2 56; }; assert_norm (pow2 56 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) in lemma_t9_fits(); calc (==) { wide_as_nat5 (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) <: int; (==) { } v t0 + v t1 * pow56 + v t2 * pow112 + v t3 * pow168 + v t4 * pow224 + v t5 * pow280 + v t6 * pow336 + v t7 * pow392 + v t8 * pow448 + v t9 * pow504; (==) { assert_norm (pow2 61 < pow2 64); Math.Lemmas.small_mod (v c8) (pow2 64) } v z0 - v c0 * pow2 56 + (v z1 + v c0 - v c1 * pow2 56) * pow56 + (v z2 + v c1 - v c2 * pow2 56) * pow112 + (v z3 + v c2 - v c3 * pow2 56) * pow168 + (v z4 + v c3 - v c4 * pow2 56) * pow224 + (v z5 + v c4 - v c5 * pow2 56) * pow280 + (v z6 + v c5 - v c6 * pow2 56) * pow336 + (v z7 + v c6 - v c7 * pow2 56) * pow392 + (v z8 + v c7 - v c8 * pow2 56) * pow448 + v c8 * pow504; (==) { lemma_mult_distr_3 (v z1) (v c0) (v c1) 56; lemma_mult_distr_3 (v z2) (v c1) (v c2) 112; lemma_mult_distr_3 (v z3) (v c2) (v c3) 168; lemma_mult_distr_3 (v z4) (v c3) (v c4) 224; lemma_mult_distr_3 (v z5) (v c4) (v c5) 280; lemma_mult_distr_3 (v z6) (v c5) (v c6) 336; lemma_mult_distr_3 (v z7) (v c6) (v c7) 392; lemma_mult_distr_3 (v z8) (v c7) (v c8) 448 } v z0 + v z1 * pow56 + v z2 * pow112 + v z3 * pow168 + v z4 * pow224 + v z5 * pow280 + v z6 * pow336 + v z7 * pow392 + v z8 * pow448; (==) { calc (==) { v z1; (==) { } v x0 * v y1 + v x1 * v y0; }; calc (==) { v z2; (==) { } v x0 * v y2 + v x1 * v y1 + v x2 * v y0; }; calc (==) { v z3; (==) { } v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0; }; calc (==) { v z4; (==) { } v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0; }; calc (==) { v z5; (==) { } v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1; }; calc (==) { v z6; (==) { } v x2 * v y4 + v x3 * v y3 + v x4 * v y2; }; calc (==) { v z7; (==) { } v x3 * v y4 + v x4 * v y3; }; calc (==) { v z8; (==) { } v x4 * v y4; } } v x0 * v y0 + (v x0 * v y1 + v x1 * v y0) * pow56 + (v x0 * v y2 + v x1 * v y1 + v x2 * v y0) * pow112 + (v x0 * v y3 + v x1 * v y2 + v x2 * v y1 + v x3 * v y0) * pow168 + (v x0 * v y4 + v x1 * v y3 + v x2 * v y2 + v x3 * v y1 + v x4 * v y0) * pow224 + (v x1 * v y4 + v x2 * v y3 + v x3 * v y2 + v x4 * v y1) * pow280 + (v x2 * v y4 + v x3 * v y3 + v x4 * v y2) * pow336 + (v x3 * v y4 + v x4 * v y3) * pow392 + (v x4 * v y4) * pow448; (==) { Lemmas.lemma_mul_qelem5 (v x0) (v x1) (v x2) (v x3) (v x4) (v y0) (v y1) (v y2) (v y3) (v y4) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224) * (v y0 + v y1 * pow2 56 + v y2 * pow2 112 + v y3 * pow2 168 + v y4 * pow2 224); }; (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) inline_for_extraction noextract val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264)
false
false
Hacl.Spec.BignumQ.Mul.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val low_mul_5: x:qelem5 -> y:qelem5 -> Pure qelem5 (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1)) (ensures fun r -> qelem_fits5 r (1, 1, 1, 1, 1) /\ as_nat5 r == (as_nat5 x * as_nat5 y) % pow2 264)
[]
Hacl.Spec.BignumQ.Mul.low_mul_5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Mul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem5 -> y: Hacl.Spec.BignumQ.Definitions.qelem5 -> Prims.Pure Hacl.Spec.BignumQ.Definitions.qelem5
{ "end_col": 22, "end_line": 628, "start_col": 57, "start_line": 582 }
Prims.Tot
[ { "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 } ]
false
let associative #a (f: (a -> a -> a)) = forall x y z. f (f x y) z == f x (f y z)
let associative #a (f: (a -> a -> a)) =
false
null
false
forall x y z. f (f x y) z == f x (f y z)
{ "checked_file": "FStar.IFC.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "FStar.IFC.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eq2", "Prims.logical" ]
[]
(* 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 FStar.IFC /// FStar.IFC provides a simple, generic abstraction for monadic /// information-flow control based on a user-defined (semi-)lattice of /// information flow labels. /// /// The main idea is to provide an abstract type [protected a l], /// encapsulating values of type [a] carrying information at /// confidentiality level [l]. Operations that compute on the /// underlying [a] are instrumented to reflect the sensitivity of /// their arguments on their results. /// /// Several papers develop this idea, ranging from /// /// Fable: A language for enforcing user-defined security policies /// http://www.cs.umd.edu/~nswamy/papers/fable-tr.pdf /// /// To more modern variants like /// https://hackage.haskell.org/package/lio (**** Basic definitions for a join semilattice *)
false
false
FStar.IFC.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val associative : f: (_: a -> _: a -> a) -> Prims.logical
[]
FStar.IFC.associative
{ "file_name": "ulib/FStar.IFC.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> _: a -> a) -> Prims.logical
{ "end_col": 80, "end_line": 40, "start_col": 40, "start_line": 40 }
Prims.Tot
[ { "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 } ]
false
let commutative #a (f: (a -> a -> a)) = forall x y. f x y == f y x
let commutative #a (f: (a -> a -> a)) =
false
null
false
forall x y. f x y == f y x
{ "checked_file": "FStar.IFC.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "FStar.IFC.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eq2", "Prims.logical" ]
[]
(* 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 FStar.IFC /// FStar.IFC provides a simple, generic abstraction for monadic /// information-flow control based on a user-defined (semi-)lattice of /// information flow labels. /// /// The main idea is to provide an abstract type [protected a l], /// encapsulating values of type [a] carrying information at /// confidentiality level [l]. Operations that compute on the /// underlying [a] are instrumented to reflect the sensitivity of /// their arguments on their results. /// /// Several papers develop this idea, ranging from /// /// Fable: A language for enforcing user-defined security policies /// http://www.cs.umd.edu/~nswamy/papers/fable-tr.pdf /// /// To more modern variants like /// https://hackage.haskell.org/package/lio (**** Basic definitions for a join semilattice *) (** The [lub] is associative *) let associative #a (f: (a -> a -> a)) = forall x y z. f (f x y) z == f x (f y z)
false
false
FStar.IFC.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val commutative : f: (_: a -> _: a -> a) -> Prims.logical
[]
FStar.IFC.commutative
{ "file_name": "ulib/FStar.IFC.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> _: a -> a) -> Prims.logical
{ "end_col": 66, "end_line": 43, "start_col": 40, "start_line": 43 }
Prims.Tot
[ { "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 } ]
false
let idempotent #a (f: (a -> a -> a)) = forall x. f x x == x
let idempotent #a (f: (a -> a -> a)) =
false
null
false
forall x. f x x == x
{ "checked_file": "FStar.IFC.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "FStar.IFC.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eq2", "Prims.logical" ]
[]
(* 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 FStar.IFC /// FStar.IFC provides a simple, generic abstraction for monadic /// information-flow control based on a user-defined (semi-)lattice of /// information flow labels. /// /// The main idea is to provide an abstract type [protected a l], /// encapsulating values of type [a] carrying information at /// confidentiality level [l]. Operations that compute on the /// underlying [a] are instrumented to reflect the sensitivity of /// their arguments on their results. /// /// Several papers develop this idea, ranging from /// /// Fable: A language for enforcing user-defined security policies /// http://www.cs.umd.edu/~nswamy/papers/fable-tr.pdf /// /// To more modern variants like /// https://hackage.haskell.org/package/lio (**** Basic definitions for a join semilattice *) (** The [lub] is associative *) let associative #a (f: (a -> a -> a)) = forall x y z. f (f x y) z == f x (f y z) (** The [lub] is commutative *) let commutative #a (f: (a -> a -> a)) = forall x y. f x y == f y x
false
false
FStar.IFC.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val idempotent : f: (_: a -> _: a -> a) -> Prims.logical
[]
FStar.IFC.idempotent
{ "file_name": "ulib/FStar.IFC.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> _: a -> a) -> Prims.logical
{ "end_col": 59, "end_line": 46, "start_col": 39, "start_line": 46 }