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.Tot
[ { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": 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 vale_cipher_alg = a: cipher_alg { a == AES128 \/ a == AES256 }
let vale_cipher_alg =
false
null
false
a: cipher_alg{a == AES128 \/ a == AES256}
{ "checked_file": "Spec.Cipher.Expansion.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.AES_s.fst.checked", "Spec.Agile.Cipher.fsti.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Spec.Cipher.Expansion.fst" }
[ "total" ]
[ "Spec.Agile.Cipher.cipher_alg", "Prims.l_or", "Prims.eq2", "Spec.Agile.Cipher.AES128", "Spec.Agile.Cipher.AES256" ]
[]
module Spec.Cipher.Expansion open Spec.Agile.Cipher
false
true
Spec.Cipher.Expansion.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vale_cipher_alg : Type0
[]
Spec.Cipher.Expansion.vale_cipher_alg
{ "file_name": "specs/Spec.Cipher.Expansion.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 66, "end_line": 5, "start_col": 22, "start_line": 5 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": 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 vale_alg_of_cipher_alg (a: cipher_alg { a == AES128 \/ a == AES256 }) = match a with | AES128 -> Vale.AES.AES_s.AES_128 | AES256 -> Vale.AES.AES_s.AES_256
let vale_alg_of_cipher_alg (a: cipher_alg{a == AES128 \/ a == AES256}) =
false
null
false
match a with | AES128 -> Vale.AES.AES_s.AES_128 | AES256 -> Vale.AES.AES_s.AES_256
{ "checked_file": "Spec.Cipher.Expansion.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.AES_s.fst.checked", "Spec.Agile.Cipher.fsti.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Spec.Cipher.Expansion.fst" }
[ "total" ]
[ "Spec.Agile.Cipher.cipher_alg", "Prims.l_or", "Prims.eq2", "Spec.Agile.Cipher.AES128", "Spec.Agile.Cipher.AES256", "Vale.AES.AES_common_s.AES_128", "Vale.AES.AES_common_s.AES_256", "Vale.AES.AES_common_s.algorithm" ]
[]
module Spec.Cipher.Expansion open Spec.Agile.Cipher let vale_cipher_alg = a: cipher_alg { a == AES128 \/ a == AES256 }
false
false
Spec.Cipher.Expansion.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vale_alg_of_cipher_alg : a: Spec.Agile.Cipher.cipher_alg{a == Spec.Agile.Cipher.AES128 \/ a == Spec.Agile.Cipher.AES256} -> Vale.AES.AES_common_s.algorithm
[]
Spec.Cipher.Expansion.vale_alg_of_cipher_alg
{ "file_name": "specs/Spec.Cipher.Expansion.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.Cipher.cipher_alg{a == Spec.Agile.Cipher.AES128 \/ a == Spec.Agile.Cipher.AES256} -> Vale.AES.AES_common_s.algorithm
{ "end_col": 36, "end_line": 10, "start_col": 2, "start_line": 8 }
Prims.Tot
val concrete_xkey_length (i: impl): Lib.IntTypes.size_nat
[ { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": 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 concrete_xkey_length (i: impl): nat = match i with | Vale_AES128 | Vale_AES256 -> vale_xkey_length (cipher_alg_of_impl i) | Hacl_CHACHA20 -> 32
val concrete_xkey_length (i: impl): Lib.IntTypes.size_nat let concrete_xkey_length (i: impl) : nat =
false
null
false
match i with | Vale_AES128 | Vale_AES256 -> vale_xkey_length (cipher_alg_of_impl i) | Hacl_CHACHA20 -> 32
{ "checked_file": "Spec.Cipher.Expansion.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.AES_s.fst.checked", "Spec.Agile.Cipher.fsti.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Spec.Cipher.Expansion.fst" }
[ "total" ]
[ "Spec.Cipher.Expansion.impl", "Spec.Cipher.Expansion.vale_xkey_length", "Spec.Cipher.Expansion.cipher_alg_of_impl", "Prims.nat", "Lib.IntTypes.size_nat" ]
[]
module Spec.Cipher.Expansion open Spec.Agile.Cipher let vale_cipher_alg = a: cipher_alg { a == AES128 \/ a == AES256 } let vale_alg_of_cipher_alg (a: cipher_alg { a == AES128 \/ a == AES256 }) = match a with | AES128 -> Vale.AES.AES_s.AES_128 | AES256 -> Vale.AES.AES_s.AES_256 #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 20" /// Length of Vale expanded keys, i.e. length of the expanded key (per NIST AES /// specification) along with other precomputed things. val vale_xkey_length (a: vale_cipher_alg): Lib.IntTypes.size_nat let vale_xkey_length = function | AES128 -> 176 + 128 // Include the hashed keys here | AES256 -> 240 + 128 // Include the hashed keys here /// Because seq_uint8_to_seq_nat8 does not take Lib.IntTypes.uint8 friend Lib.IntTypes /// And the specification of the Vale key expansion. val vale_aes_expansion (a: vale_cipher_alg) (key: key a): Lib.ByteSequence.lbytes (vale_xkey_length a) let vale_aes_expansion a k = let open Vale.AES.AES_s in assert_norm (32 % 4 = 0); assert_norm (16 % 4 = 0); let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let ekv_w = key_to_round_keys_LE (vale_alg_of_cipher_alg a) k_w in let ekv_nat = Vale.Def.Types_s.le_seq_quad32_to_bytes ekv_w in Vale.Def.Types_s.le_seq_quad32_to_bytes_length ekv_w; let ek = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 ekv_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( aes_encrypt_LE (vale_alg_of_cipher_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in Seq.append ek hkeys let _: squash (inversion cipher_alg) = allow_inversion cipher_alg let _: squash (inversion impl) = allow_inversion impl let xkey_length = function | CHACHA20 -> 32 | AES128 -> 176 | AES256 -> 240
false
true
Spec.Cipher.Expansion.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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val concrete_xkey_length (i: impl): Lib.IntTypes.size_nat
[]
Spec.Cipher.Expansion.concrete_xkey_length
{ "file_name": "specs/Spec.Cipher.Expansion.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Spec.Cipher.Expansion.impl -> Lib.IntTypes.size_nat
{ "end_col": 23, "end_line": 57, "start_col": 2, "start_line": 53 }
Prims.Tot
val xkey_length (a: cipher_alg): Lib.IntTypes.size_nat
[ { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": 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 xkey_length = function | CHACHA20 -> 32 | AES128 -> 176 | AES256 -> 240
val xkey_length (a: cipher_alg): Lib.IntTypes.size_nat let xkey_length =
false
null
false
function | CHACHA20 -> 32 | AES128 -> 176 | AES256 -> 240
{ "checked_file": "Spec.Cipher.Expansion.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.AES_s.fst.checked", "Spec.Agile.Cipher.fsti.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Spec.Cipher.Expansion.fst" }
[ "total" ]
[ "Spec.Agile.Cipher.cipher_alg", "Lib.IntTypes.size_nat" ]
[]
module Spec.Cipher.Expansion open Spec.Agile.Cipher let vale_cipher_alg = a: cipher_alg { a == AES128 \/ a == AES256 } let vale_alg_of_cipher_alg (a: cipher_alg { a == AES128 \/ a == AES256 }) = match a with | AES128 -> Vale.AES.AES_s.AES_128 | AES256 -> Vale.AES.AES_s.AES_256 #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 20" /// Length of Vale expanded keys, i.e. length of the expanded key (per NIST AES /// specification) along with other precomputed things. val vale_xkey_length (a: vale_cipher_alg): Lib.IntTypes.size_nat let vale_xkey_length = function | AES128 -> 176 + 128 // Include the hashed keys here | AES256 -> 240 + 128 // Include the hashed keys here /// Because seq_uint8_to_seq_nat8 does not take Lib.IntTypes.uint8 friend Lib.IntTypes /// And the specification of the Vale key expansion. val vale_aes_expansion (a: vale_cipher_alg) (key: key a): Lib.ByteSequence.lbytes (vale_xkey_length a) let vale_aes_expansion a k = let open Vale.AES.AES_s in assert_norm (32 % 4 = 0); assert_norm (16 % 4 = 0); let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let ekv_w = key_to_round_keys_LE (vale_alg_of_cipher_alg a) k_w in let ekv_nat = Vale.Def.Types_s.le_seq_quad32_to_bytes ekv_w in Vale.Def.Types_s.le_seq_quad32_to_bytes_length ekv_w; let ek = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 ekv_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( aes_encrypt_LE (vale_alg_of_cipher_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in Seq.append ek hkeys let _: squash (inversion cipher_alg) = allow_inversion cipher_alg let _: squash (inversion impl) = allow_inversion impl
false
true
Spec.Cipher.Expansion.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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val xkey_length (a: cipher_alg): Lib.IntTypes.size_nat
[]
Spec.Cipher.Expansion.xkey_length
{ "file_name": "specs/Spec.Cipher.Expansion.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.Cipher.cipher_alg -> Lib.IntTypes.size_nat
{ "end_col": 17, "end_line": 50, "start_col": 2, "start_line": 47 }
Prims.Tot
val vale_xkey_length (a: vale_cipher_alg): Lib.IntTypes.size_nat
[ { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": 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 vale_xkey_length = function | AES128 -> 176 + 128 // Include the hashed keys here | AES256 -> 240 + 128
val vale_xkey_length (a: vale_cipher_alg): Lib.IntTypes.size_nat let vale_xkey_length =
false
null
false
function | AES128 -> 176 + 128 | AES256 -> 240 + 128
{ "checked_file": "Spec.Cipher.Expansion.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.AES_s.fst.checked", "Spec.Agile.Cipher.fsti.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Spec.Cipher.Expansion.fst" }
[ "total" ]
[ "Spec.Cipher.Expansion.vale_cipher_alg", "Prims.op_Addition", "Lib.IntTypes.size_nat" ]
[]
module Spec.Cipher.Expansion open Spec.Agile.Cipher let vale_cipher_alg = a: cipher_alg { a == AES128 \/ a == AES256 } let vale_alg_of_cipher_alg (a: cipher_alg { a == AES128 \/ a == AES256 }) = match a with | AES128 -> Vale.AES.AES_s.AES_128 | AES256 -> Vale.AES.AES_s.AES_256 #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 20" /// Length of Vale expanded keys, i.e. length of the expanded key (per NIST AES /// specification) along with other precomputed things. val vale_xkey_length (a: vale_cipher_alg): Lib.IntTypes.size_nat
false
true
Spec.Cipher.Expansion.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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vale_xkey_length (a: vale_cipher_alg): Lib.IntTypes.size_nat
[]
Spec.Cipher.Expansion.vale_xkey_length
{ "file_name": "specs/Spec.Cipher.Expansion.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Cipher.Expansion.vale_cipher_alg -> Lib.IntTypes.size_nat
{ "end_col": 23, "end_line": 20, "start_col": 2, "start_line": 18 }
Prims.Tot
val concrete_expand: i:impl -> key (cipher_alg_of_impl i) -> concrete_xkey i
[ { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": 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 concrete_expand i k = match i with | Hacl_CHACHA20 -> k | Vale_AES128 | Vale_AES256 -> let a = cipher_alg_of_impl i in vale_aes_expansion a k
val concrete_expand: i:impl -> key (cipher_alg_of_impl i) -> concrete_xkey i let concrete_expand i k =
false
null
false
match i with | Hacl_CHACHA20 -> k | Vale_AES128 | Vale_AES256 -> let a = cipher_alg_of_impl i in vale_aes_expansion a k
{ "checked_file": "Spec.Cipher.Expansion.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.AES_s.fst.checked", "Spec.Agile.Cipher.fsti.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Spec.Cipher.Expansion.fst" }
[ "total" ]
[ "Spec.Cipher.Expansion.impl", "Spec.Agile.Cipher.key", "Spec.Cipher.Expansion.cipher_alg_of_impl", "Spec.Cipher.Expansion.vale_aes_expansion", "Spec.Agile.Cipher.cipher_alg", "Spec.Cipher.Expansion.concrete_xkey" ]
[]
module Spec.Cipher.Expansion open Spec.Agile.Cipher let vale_cipher_alg = a: cipher_alg { a == AES128 \/ a == AES256 } let vale_alg_of_cipher_alg (a: cipher_alg { a == AES128 \/ a == AES256 }) = match a with | AES128 -> Vale.AES.AES_s.AES_128 | AES256 -> Vale.AES.AES_s.AES_256 #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 20" /// Length of Vale expanded keys, i.e. length of the expanded key (per NIST AES /// specification) along with other precomputed things. val vale_xkey_length (a: vale_cipher_alg): Lib.IntTypes.size_nat let vale_xkey_length = function | AES128 -> 176 + 128 // Include the hashed keys here | AES256 -> 240 + 128 // Include the hashed keys here /// Because seq_uint8_to_seq_nat8 does not take Lib.IntTypes.uint8 friend Lib.IntTypes /// And the specification of the Vale key expansion. val vale_aes_expansion (a: vale_cipher_alg) (key: key a): Lib.ByteSequence.lbytes (vale_xkey_length a) let vale_aes_expansion a k = let open Vale.AES.AES_s in assert_norm (32 % 4 = 0); assert_norm (16 % 4 = 0); let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let ekv_w = key_to_round_keys_LE (vale_alg_of_cipher_alg a) k_w in let ekv_nat = Vale.Def.Types_s.le_seq_quad32_to_bytes ekv_w in Vale.Def.Types_s.le_seq_quad32_to_bytes_length ekv_w; let ek = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 ekv_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( aes_encrypt_LE (vale_alg_of_cipher_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in Seq.append ek hkeys let _: squash (inversion cipher_alg) = allow_inversion cipher_alg let _: squash (inversion impl) = allow_inversion impl let xkey_length = function | CHACHA20 -> 32 | AES128 -> 176 | AES256 -> 240 let concrete_xkey_length (i: impl): nat = match i with | Vale_AES128 | Vale_AES256 -> vale_xkey_length (cipher_alg_of_impl i) | Hacl_CHACHA20 -> 32
false
false
Spec.Cipher.Expansion.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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val concrete_expand: i:impl -> key (cipher_alg_of_impl i) -> concrete_xkey i
[]
Spec.Cipher.Expansion.concrete_expand
{ "file_name": "specs/Spec.Cipher.Expansion.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Spec.Cipher.Expansion.impl -> k: Spec.Agile.Cipher.key (Spec.Cipher.Expansion.cipher_alg_of_impl i) -> Spec.Cipher.Expansion.concrete_xkey i
{ "end_col": 28, "end_line": 64, "start_col": 2, "start_line": 60 }
Prims.Tot
val vale_aes_expansion (a: vale_cipher_alg) (key: key a): Lib.ByteSequence.lbytes (vale_xkey_length a)
[ { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Cipher", "short_module": null }, { "abbrev": 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 vale_aes_expansion a k = let open Vale.AES.AES_s in assert_norm (32 % 4 = 0); assert_norm (16 % 4 = 0); let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let ekv_w = key_to_round_keys_LE (vale_alg_of_cipher_alg a) k_w in let ekv_nat = Vale.Def.Types_s.le_seq_quad32_to_bytes ekv_w in Vale.Def.Types_s.le_seq_quad32_to_bytes_length ekv_w; let ek = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 ekv_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 ( aes_encrypt_LE (vale_alg_of_cipher_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in Seq.append ek hkeys
val vale_aes_expansion (a: vale_cipher_alg) (key: key a): Lib.ByteSequence.lbytes (vale_xkey_length a) let vale_aes_expansion a k =
false
null
false
let open Vale.AES.AES_s in assert_norm (32 % 4 = 0); assert_norm (16 % 4 = 0); let k_nat = Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 k in let k_w = Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE k_nat in let ekv_w = key_to_round_keys_LE (vale_alg_of_cipher_alg a) k_w in let ekv_nat = Vale.Def.Types_s.le_seq_quad32_to_bytes ekv_w in Vale.Def.Types_s.le_seq_quad32_to_bytes_length ekv_w; let ek = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 ekv_nat in let hkeys_quad = Vale.AES.OptPublic.get_hkeys_reqs (Vale.Def.Types_s.reverse_bytes_quad32 (aes_encrypt_LE (vale_alg_of_cipher_alg a) k_w (Vale.Def.Words_s.Mkfour 0 0 0 0))) in let hkeys = Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes hkeys_quad) in Seq.append ek hkeys
{ "checked_file": "Spec.Cipher.Expansion.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.AES_s.fst.checked", "Spec.Agile.Cipher.fsti.checked", "prims.fst.checked", "Lib.IntTypes.fst.checked", "Lib.IntTypes.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Spec.Cipher.Expansion.fst" }
[ "total" ]
[ "Spec.Cipher.Expansion.vale_cipher_alg", "Spec.Agile.Cipher.key", "FStar.Seq.Base.append", "FStar.UInt8.t", "FStar.Seq.Base.seq", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "FStar.Seq.Properties.lseq", "Vale.Def.Types_s.quad32", "Vale.AES.OptPublic.hkeys_reqs_pub", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.AES.AES_s.aes_encrypt_LE", "Spec.Cipher.Expansion.vale_alg_of_cipher_alg", "Vale.Def.Words_s.Mkfour", "Vale.Def.Words_s.nat32", "Vale.AES.OptPublic.get_hkeys_reqs", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.Def.Types_s.le_seq_quad32_to_bytes_length", "Vale.Def.Words_s.nat8", "Vale.AES.AES_s.key_to_round_keys_LE", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE", "Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Lib.ByteSequence.lbytes", "Spec.Cipher.Expansion.vale_xkey_length" ]
[]
module Spec.Cipher.Expansion open Spec.Agile.Cipher let vale_cipher_alg = a: cipher_alg { a == AES128 \/ a == AES256 } let vale_alg_of_cipher_alg (a: cipher_alg { a == AES128 \/ a == AES256 }) = match a with | AES128 -> Vale.AES.AES_s.AES_128 | AES256 -> Vale.AES.AES_s.AES_256 #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 20" /// Length of Vale expanded keys, i.e. length of the expanded key (per NIST AES /// specification) along with other precomputed things. val vale_xkey_length (a: vale_cipher_alg): Lib.IntTypes.size_nat let vale_xkey_length = function | AES128 -> 176 + 128 // Include the hashed keys here | AES256 -> 240 + 128 // Include the hashed keys here /// Because seq_uint8_to_seq_nat8 does not take Lib.IntTypes.uint8 friend Lib.IntTypes /// And the specification of the Vale key expansion. val vale_aes_expansion (a: vale_cipher_alg) (key: key a): Lib.ByteSequence.lbytes (vale_xkey_length a)
false
false
Spec.Cipher.Expansion.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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vale_aes_expansion (a: vale_cipher_alg) (key: key a): Lib.ByteSequence.lbytes (vale_xkey_length a)
[]
Spec.Cipher.Expansion.vale_aes_expansion
{ "file_name": "specs/Spec.Cipher.Expansion.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Cipher.Expansion.vale_cipher_alg -> key: Spec.Agile.Cipher.key a -> Lib.ByteSequence.lbytes (Spec.Cipher.Expansion.vale_xkey_length a)
{ "end_col": 21, "end_line": 41, "start_col": 2, "start_line": 29 }
Prims.GTot
val contains (#a: Type0) (h: heap) (r: ref a) : GTot Type0
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r
val contains (#a: Type0) (h: heap) (r: ref a) : GTot Type0 let contains (#a: Type0) (h: heap) (r: ref a) : GTot Type0 =
false
null
false
Heap.contains h r
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[ "sometrivial" ]
[ "FStar.Monotonic.Heap.heap", "FStar.ST.ref", "FStar.Monotonic.Heap.contains", "FStar.Heap.trivial_preorder" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold
false
false
FStar.Ref.fst
{ "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 contains (#a: Type0) (h: heap) (r: ref a) : GTot Type0
[]
FStar.Ref.contains
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
h: FStar.Monotonic.Heap.heap -> r: FStar.ST.ref a -> Prims.GTot Type0
{ "end_col": 21, "end_line": 39, "start_col": 4, "start_line": 39 }
Prims.GTot
val sel (#a: Type0) (h: heap) (r: ref a) : GTot a
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r
val sel (#a: Type0) (h: heap) (r: ref a) : GTot a let sel (#a: Type0) (h: heap) (r: ref a) : GTot a =
false
null
false
Heap.sel h r
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[ "sometrivial" ]
[ "FStar.Monotonic.Heap.heap", "FStar.ST.ref", "FStar.Monotonic.Heap.sel", "FStar.Heap.trivial_preorder" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold
false
false
FStar.Ref.fst
{ "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 sel (#a: Type0) (h: heap) (r: ref a) : GTot a
[]
FStar.Ref.sel
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
h: FStar.Monotonic.Heap.heap -> r: FStar.ST.ref a -> Prims.GTot a
{ "end_col": 16, "end_line": 28, "start_col": 4, "start_line": 28 }
FStar.ST.STATE
val recall (#a:Type0) (r:ref a) : STATE unit (fun p h -> h `contains` r ==> p () h)
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 recall #_ r = recall r
val recall (#a:Type0) (r:ref a) : STATE unit (fun p h -> h `contains` r ==> p () h) let recall #_ r =
true
null
false
recall r
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[]
[ "FStar.ST.ref", "FStar.ST.recall", "FStar.Heap.trivial_preorder", "Prims.unit" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold let contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r unfold let unused_in (#a:Type0) (r:ref a) (h:heap) :GTot Type0 = Heap.unused_in r h unfold let fresh (#a:Type0) (r:ref a) (h0:heap) (h1:heap) : Type0 = Heap.fresh r h0 h1 unfold let only (#a:Type0) (r:ref a) :GTot (Set.set nat) = Heap.only r
false
false
FStar.Ref.fst
{ "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 recall (#a:Type0) (r:ref a) : STATE unit (fun p h -> h `contains` r ==> p () h)
[]
FStar.Ref.recall
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.ref a -> FStar.ST.STATE Prims.unit
{ "end_col": 26, "end_line": 54, "start_col": 18, "start_line": 54 }
Prims.GTot
val unused_in (#a: Type0) (r: ref a) (h: heap) : GTot Type0
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 unused_in (#a:Type0) (r:ref a) (h:heap) :GTot Type0 = Heap.unused_in r h
val unused_in (#a: Type0) (r: ref a) (h: heap) : GTot Type0 let unused_in (#a: Type0) (r: ref a) (h: heap) : GTot Type0 =
false
null
false
Heap.unused_in r h
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[ "sometrivial" ]
[ "FStar.ST.ref", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.Heap.unused_in", "FStar.Heap.trivial_preorder" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold let contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r unfold
false
false
FStar.Ref.fst
{ "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 unused_in (#a: Type0) (r: ref a) (h: heap) : GTot Type0
[]
FStar.Ref.unused_in
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.ref a -> h: FStar.Monotonic.Heap.heap -> Prims.GTot Type0
{ "end_col": 22, "end_line": 43, "start_col": 4, "start_line": 43 }
Prims.Tot
val fresh (#a: Type0) (r: ref a) (h0 h1: heap) : Type0
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 fresh (#a:Type0) (r:ref a) (h0:heap) (h1:heap) : Type0 = Heap.fresh r h0 h1
val fresh (#a: Type0) (r: ref a) (h0 h1: heap) : Type0 let fresh (#a: Type0) (r: ref a) (h0 h1: heap) : Type0 =
false
null
false
Heap.fresh r h0 h1
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[ "total" ]
[ "FStar.ST.ref", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.Heap.fresh", "FStar.Heap.trivial_preorder" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold let contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r unfold let unused_in (#a:Type0) (r:ref a) (h:heap) :GTot Type0 = Heap.unused_in r h unfold
false
false
FStar.Ref.fst
{ "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 fresh (#a: Type0) (r: ref a) (h0 h1: heap) : Type0
[]
FStar.Ref.fresh
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.ref a -> h0: FStar.Monotonic.Heap.heap -> h1: FStar.Monotonic.Heap.heap -> Type0
{ "end_col": 22, "end_line": 47, "start_col": 4, "start_line": 47 }
Prims.GTot
val upd (#a: Type0) (h: heap) (r: ref a) (v: a) : GTot heap
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v
val upd (#a: Type0) (h: heap) (r: ref a) (v: a) : GTot heap let upd (#a: Type0) (h: heap) (r: ref a) (v: a) : GTot heap =
false
null
false
Heap.upd h r v
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[ "sometrivial" ]
[ "FStar.Monotonic.Heap.heap", "FStar.ST.ref", "FStar.Monotonic.Heap.upd", "FStar.Heap.trivial_preorder" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold
false
false
FStar.Ref.fst
{ "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 upd (#a: Type0) (h: heap) (r: ref a) (v: a) : GTot heap
[]
FStar.Ref.upd
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
h: FStar.Monotonic.Heap.heap -> r: FStar.ST.ref a -> v: a -> Prims.GTot FStar.Monotonic.Heap.heap
{ "end_col": 18, "end_line": 32, "start_col": 4, "start_line": 32 }
FStar.ST.STATE
val op_Bang (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h)
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 op_Bang #_ r = read r
val op_Bang (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h) let op_Bang #_ r =
true
null
false
read r
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[]
[ "FStar.ST.ref", "FStar.Ref.read" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold let contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r unfold let unused_in (#a:Type0) (r:ref a) (h:heap) :GTot Type0 = Heap.unused_in r h unfold let fresh (#a:Type0) (r:ref a) (h0:heap) (h1:heap) : Type0 = Heap.fresh r h0 h1 unfold let only (#a:Type0) (r:ref a) :GTot (Set.set nat) = Heap.only r val recall (#a:Type0) (r:ref a) : STATE unit (fun p h -> h `contains` r ==> p () h) let recall #_ r = recall r val alloc (#a:Type0) (init:a) :ST (ref a) (fun _ -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) let alloc #_ init = alloc init val read (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h) let read #_ r = read r val write (#a:Type0) (r:ref a) (v:a) :ST unit (fun _ -> True) (fun h0 _ h1 -> h0 `contains` r /\ modifies (only r) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) let write #_ r v = write r v
false
false
FStar.Ref.fst
{ "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 op_Bang (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h)
[]
FStar.Ref.op_Bang
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.ref a -> FStar.ST.STATE a
{ "end_col": 25, "end_line": 70, "start_col": 19, "start_line": 70 }
FStar.ST.STATE
val read (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h)
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 read #_ r = read r
val read (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h) let read #_ r =
true
null
false
read r
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[]
[ "FStar.ST.ref", "FStar.ST.read", "FStar.Heap.trivial_preorder" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold let contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r unfold let unused_in (#a:Type0) (r:ref a) (h:heap) :GTot Type0 = Heap.unused_in r h unfold let fresh (#a:Type0) (r:ref a) (h0:heap) (h1:heap) : Type0 = Heap.fresh r h0 h1 unfold let only (#a:Type0) (r:ref a) :GTot (Set.set nat) = Heap.only r val recall (#a:Type0) (r:ref a) : STATE unit (fun p h -> h `contains` r ==> p () h) let recall #_ r = recall r val alloc (#a:Type0) (init:a) :ST (ref a) (fun _ -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) let alloc #_ init = alloc init
false
false
FStar.Ref.fst
{ "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 read (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h)
[]
FStar.Ref.read
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.ref a -> FStar.ST.STATE a
{ "end_col": 22, "end_line": 63, "start_col": 16, "start_line": 63 }
FStar.ST.ST
val op_Colon_Equals (#a:Type0) (r:ref a) (v:a) :ST unit (fun _ -> True) (fun h0 _ h1 -> h0 `contains` r /\ modifies (only r) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v)
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 op_Colon_Equals #_ r v = write r v
val op_Colon_Equals (#a:Type0) (r:ref a) (v:a) :ST unit (fun _ -> True) (fun h0 _ h1 -> h0 `contains` r /\ modifies (only r) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) let op_Colon_Equals #_ r v =
true
null
false
write r v
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[]
[ "FStar.ST.ref", "FStar.Ref.write", "Prims.unit" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold let contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r unfold let unused_in (#a:Type0) (r:ref a) (h:heap) :GTot Type0 = Heap.unused_in r h unfold let fresh (#a:Type0) (r:ref a) (h0:heap) (h1:heap) : Type0 = Heap.fresh r h0 h1 unfold let only (#a:Type0) (r:ref a) :GTot (Set.set nat) = Heap.only r val recall (#a:Type0) (r:ref a) : STATE unit (fun p h -> h `contains` r ==> p () h) let recall #_ r = recall r val alloc (#a:Type0) (init:a) :ST (ref a) (fun _ -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) let alloc #_ init = alloc init val read (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h) let read #_ r = read r val write (#a:Type0) (r:ref a) (v:a) :ST unit (fun _ -> True) (fun h0 _ h1 -> h0 `contains` r /\ modifies (only r) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) let write #_ r v = write r v val op_Bang (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h) let op_Bang #_ r = read r val op_Colon_Equals (#a:Type0) (r:ref a) (v:a)
false
false
FStar.Ref.fst
{ "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 op_Colon_Equals (#a:Type0) (r:ref a) (v:a) :ST unit (fun _ -> True) (fun h0 _ h1 -> h0 `contains` r /\ modifies (only r) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v)
[]
FStar.Ref.op_Colon_Equals
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.ref a -> v: a -> FStar.ST.ST Prims.unit
{ "end_col": 38, "end_line": 74, "start_col": 29, "start_line": 74 }
Prims.GTot
val addr_of (#a: Type0) (r: ref a) : GTot nat
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r
val addr_of (#a: Type0) (r: ref a) : GTot nat let addr_of (#a: Type0) (r: ref a) : GTot nat =
false
null
false
addr_of r
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[ "sometrivial" ]
[ "FStar.ST.ref", "FStar.Monotonic.Heap.addr_of", "FStar.Heap.trivial_preorder", "Prims.nat" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v
false
false
FStar.Ref.fst
{ "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 addr_of (#a: Type0) (r: ref a) : GTot nat
[]
FStar.Ref.addr_of
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.ref a -> Prims.GTot Prims.nat
{ "end_col": 55, "end_line": 35, "start_col": 46, "start_line": 35 }
FStar.ST.ST
val write (#a:Type0) (r:ref a) (v:a) :ST unit (fun _ -> True) (fun h0 _ h1 -> h0 `contains` r /\ modifies (only r) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v)
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 write #_ r v = write r v
val write (#a:Type0) (r:ref a) (v:a) :ST unit (fun _ -> True) (fun h0 _ h1 -> h0 `contains` r /\ modifies (only r) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) let write #_ r v =
true
null
false
write r v
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[]
[ "FStar.ST.ref", "FStar.ST.write", "FStar.Heap.trivial_preorder", "Prims.unit" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold let contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r unfold let unused_in (#a:Type0) (r:ref a) (h:heap) :GTot Type0 = Heap.unused_in r h unfold let fresh (#a:Type0) (r:ref a) (h0:heap) (h1:heap) : Type0 = Heap.fresh r h0 h1 unfold let only (#a:Type0) (r:ref a) :GTot (Set.set nat) = Heap.only r val recall (#a:Type0) (r:ref a) : STATE unit (fun p h -> h `contains` r ==> p () h) let recall #_ r = recall r val alloc (#a:Type0) (init:a) :ST (ref a) (fun _ -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) let alloc #_ init = alloc init val read (#a:Type0) (r:ref a) :STATE a (fun p h -> p (sel h r) h) let read #_ r = read r val write (#a:Type0) (r:ref a) (v:a)
false
false
FStar.Ref.fst
{ "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 write (#a:Type0) (r:ref a) (v:a) :ST unit (fun _ -> True) (fun h0 _ h1 -> h0 `contains` r /\ modifies (only r) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v)
[]
FStar.Ref.write
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.ref a -> v: a -> FStar.ST.ST Prims.unit
{ "end_col": 28, "end_line": 67, "start_col": 19, "start_line": 67 }
Prims.GTot
val only (#a: Type0) (r: ref a) : GTot (Set.set nat)
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 only (#a:Type0) (r:ref a) :GTot (Set.set nat) = Heap.only r
val only (#a: Type0) (r: ref a) : GTot (Set.set nat) let only (#a: Type0) (r: ref a) : GTot (Set.set nat) =
false
null
false
Heap.only r
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[ "sometrivial" ]
[ "FStar.ST.ref", "FStar.Monotonic.Heap.only", "FStar.Heap.trivial_preorder", "FStar.Set.set", "Prims.nat" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold let contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r unfold let unused_in (#a:Type0) (r:ref a) (h:heap) :GTot Type0 = Heap.unused_in r h unfold let fresh (#a:Type0) (r:ref a) (h0:heap) (h1:heap) : Type0 = Heap.fresh r h0 h1 unfold
false
false
FStar.Ref.fst
{ "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 only (#a: Type0) (r: ref a) : GTot (Set.set nat)
[]
FStar.Ref.only
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.ref a -> Prims.GTot (FStar.Set.set Prims.nat)
{ "end_col": 15, "end_line": 51, "start_col": 4, "start_line": 51 }
FStar.ST.ST
val alloc (#a:Type0) (init:a) :ST (ref a) (fun _ -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init)
[ { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "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 alloc #_ init = alloc init
val alloc (#a:Type0) (init:a) :ST (ref a) (fun _ -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) let alloc #_ init =
true
null
false
alloc init
{ "checked_file": "FStar.Ref.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.ST.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.Ref.fst" }
[]
[ "FStar.ST.alloc", "FStar.Heap.trivial_preorder", "FStar.ST.mref", "FStar.ST.ref" ]
[]
(* 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.Ref (* wrapper over FStar.ST to provide operations over refs with default preorder *) include FStar.Heap include FStar.ST open FStar.Heap open FStar.ST unfold let sel (#a:Type0) (h:heap) (r:ref a) : GTot a = Heap.sel h r unfold let upd (#a:Type0) (h:heap) (r:ref a) (v:a) :GTot heap = Heap.upd h r v unfold let addr_of (#a:Type0) (r:ref a) : GTot nat = addr_of r unfold let contains (#a:Type0) (h:heap) (r:ref a) :GTot Type0 = Heap.contains h r unfold let unused_in (#a:Type0) (r:ref a) (h:heap) :GTot Type0 = Heap.unused_in r h unfold let fresh (#a:Type0) (r:ref a) (h0:heap) (h1:heap) : Type0 = Heap.fresh r h0 h1 unfold let only (#a:Type0) (r:ref a) :GTot (Set.set nat) = Heap.only r val recall (#a:Type0) (r:ref a) : STATE unit (fun p h -> h `contains` r ==> p () h) let recall #_ r = recall r val alloc (#a:Type0) (init:a) :ST (ref a) (fun _ -> True)
false
false
FStar.Ref.fst
{ "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 alloc (#a:Type0) (init:a) :ST (ref a) (fun _ -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init)
[]
FStar.Ref.alloc
{ "file_name": "ulib/FStar.Ref.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
init: a -> FStar.ST.ST (FStar.ST.ref a)
{ "end_col": 30, "end_line": 60, "start_col": 20, "start_line": 60 }
Prims.Tot
val bn_mul1_lshift_add: #t:limb_t -> #aLen:size_nat -> #resLen:size_nat -> a:lbignum t aLen -> b:limb t -> j:size_nat{j + aLen <= resLen} -> acc:lbignum t resLen -> limb t & lbignum t resLen
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc
val bn_mul1_lshift_add: #t:limb_t -> #aLen:size_nat -> #resLen:size_nat -> a:lbignum t aLen -> b:limb t -> j:size_nat{j + aLen <= resLen} -> acc:lbignum t resLen -> limb t & lbignum t resLen let bn_mul1_lshift_add #t #aLen #resLen a b j acc =
false
null
false
Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a
false
false
Hacl.Spec.Bignum.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_mul1_lshift_add: #t:limb_t -> #aLen:size_nat -> #resLen:size_nat -> a:lbignum t aLen -> b:limb t -> j:size_nat{j + aLen <= resLen} -> acc:lbignum t resLen -> limb t & lbignum t resLen
[]
Hacl.Spec.Bignum.bn_mul1_lshift_add
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.limb t -> j: Lib.IntTypes.size_nat{j + aLen <= resLen} -> acc: Hacl.Spec.Bignum.Definitions.lbignum t resLen -> Hacl.Spec.Bignum.Definitions.limb t * Hacl.Spec.Bignum.Definitions.lbignum t resLen
{ "end_col": 62, "end_line": 148, "start_col": 2, "start_line": 148 }
Prims.Tot
val bn_gt_pow2_mask: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> limb t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x
val bn_gt_pow2_mask: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> limb t let bn_gt_pow2_mask #t #len b x =
false
null
false
Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask", "Hacl.Spec.Bignum.Definitions.limb" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x
false
false
Hacl.Spec.Bignum.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_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> limb t
[]
Hacl.Spec.Bignum.bn_gt_pow2_mask
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> x: Lib.IntTypes.size_nat{x < Lib.IntTypes.bits t * len} -> Hacl.Spec.Bignum.Definitions.limb t
{ "end_col": 49, "end_line": 243, "start_col": 2, "start_line": 243 }
Prims.Tot
val bn_mul1: #t:limb_t -> #aLen:size_nat -> a:lbignum t aLen -> b1:limb t -> limb t & lbignum t aLen
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1
val bn_mul1: #t:limb_t -> #aLen:size_nat -> a:lbignum t aLen -> b1:limb t -> limb t & lbignum t aLen let bn_mul1 #t #aLen a b1 =
false
null
false
Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Multiplication.bn_mul1", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end
false
false
Hacl.Spec.Bignum.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_mul1: #t:limb_t -> #aLen:size_nat -> a:lbignum t aLen -> b1:limb t -> limb t & lbignum t aLen
[]
Hacl.Spec.Bignum.bn_mul1
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b1: Hacl.Spec.Bignum.Definitions.limb t -> Hacl.Spec.Bignum.Definitions.limb t * Hacl.Spec.Bignum.Definitions.lbignum t aLen
{ "end_col": 46, "end_line": 118, "start_col": 2, "start_line": 118 }
Prims.Tot
val bn_lt_pow2_mask: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> limb t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x
val bn_lt_pow2_mask: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> limb t let bn_lt_pow2_mask #t #len b x =
false
null
false
Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask", "Hacl.Spec.Bignum.Definitions.limb" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b
false
false
Hacl.Spec.Bignum.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_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> limb t
[]
Hacl.Spec.Bignum.bn_lt_pow2_mask
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> x: Lib.IntTypes.size_nat{x < Lib.IntTypes.bits t * len} -> Hacl.Spec.Bignum.Definitions.limb t
{ "end_col": 49, "end_line": 237, "start_col": 2, "start_line": 237 }
Prims.Tot
val bn_add: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> carry t & lbignum t aLen
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b
val bn_add: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> carry t & lbignum t aLen let bn_add #t #aLen #bLen a b =
false
null
false
Hacl.Spec.Bignum.Addition.bn_add a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Addition.bn_add", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Base.carry" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1
false
false
Hacl.Spec.Bignum.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_add: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> carry t & lbignum t aLen
[]
Hacl.Spec.Bignum.bn_add
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.lbignum t bLen -> Hacl.Spec.Bignum.Base.carry t * Hacl.Spec.Bignum.Definitions.lbignum t aLen
{ "end_col": 38, "end_line": 21, "start_col": 2, "start_line": 21 }
Prims.Tot
val bn_eq_mask: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> limb t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b
val bn_eq_mask: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> limb t let bn_eq_mask #t #len a b =
false
null
false
Hacl.Spec.Bignum.Comparison.bn_eq_mask a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Comparison.bn_eq_mask", "Hacl.Spec.Bignum.Definitions.limb" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b
false
false
Hacl.Spec.Bignum.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_nat -> a:lbignum t len -> b:lbignum t len -> limb t
[]
Hacl.Spec.Bignum.bn_eq_mask
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t len -> b: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.limb t
{ "end_col": 44, "end_line": 219, "start_col": 2, "start_line": 219 }
Prims.Tot
val cswap2: #t:limb_t -> #len:size_nat -> bit:limb t -> b1:lbignum t len -> b2:lbignum t len -> tuple2 (lbignum t len) (lbignum t len)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2
val cswap2: #t:limb_t -> #len:size_nat -> bit:limb t -> b1:lbignum t len -> b2:lbignum t len -> tuple2 (lbignum t len) (lbignum t len) let cswap2 #t #len bit b1 b2 =
false
null
false
Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Lib.cswap2", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *)
false
false
Hacl.Spec.Bignum.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 cswap2: #t:limb_t -> #len:size_nat -> bit:limb t -> b1:lbignum t len -> b2:lbignum t len -> tuple2 (lbignum t len) (lbignum t len)
[]
Hacl.Spec.Bignum.cswap2
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bit: Hacl.Spec.Bignum.Definitions.limb t -> b1: Hacl.Spec.Bignum.Definitions.lbignum t len -> b2: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.lbignum t len * Hacl.Spec.Bignum.Definitions.lbignum t len
{ "end_col": 39, "end_line": 205, "start_col": 2, "start_line": 205 }
Prims.Tot
val bn_is_zero_mask: #t:limb_t -> #len:size_nat -> a:lbignum t len -> limb t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b
val bn_is_zero_mask: #t:limb_t -> #len:size_nat -> a:lbignum t len -> limb t let bn_is_zero_mask #t #len b =
false
null
false
Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Comparison.bn_is_zero_mask", "Hacl.Spec.Bignum.Definitions.limb" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b
false
false
Hacl.Spec.Bignum.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_nat -> a:lbignum t len -> limb t
[]
Hacl.Spec.Bignum.bn_is_zero_mask
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.limb t
{ "end_col": 47, "end_line": 225, "start_col": 2, "start_line": 225 }
Prims.Tot
val bn_sub: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> carry t & lbignum t aLen
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b
val bn_sub: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> carry t & lbignum t aLen let bn_sub #t #aLen #bLen a b =
false
null
false
Hacl.Spec.Bignum.Addition.bn_sub a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Addition.bn_sub", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Base.carry" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b
false
false
Hacl.Spec.Bignum.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_sub: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> carry t & lbignum t aLen
[]
Hacl.Spec.Bignum.bn_sub
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.lbignum t bLen -> Hacl.Spec.Bignum.Base.carry t * Hacl.Spec.Bignum.Definitions.lbignum t aLen
{ "end_col": 38, "end_line": 27, "start_col": 2, "start_line": 27 }
Prims.Tot
val bn_lt_mask: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> limb t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b
val bn_lt_mask: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> limb t let bn_lt_mask #t #len a b =
false
null
false
Hacl.Spec.Bignum.Comparison.bn_lt_mask a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Comparison.bn_lt_mask", "Hacl.Spec.Bignum.Definitions.limb" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b
false
false
Hacl.Spec.Bignum.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_nat -> a:lbignum t len -> b:lbignum t len -> limb t
[]
Hacl.Spec.Bignum.bn_lt_mask
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t len -> b: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.limb t
{ "end_col": 44, "end_line": 231, "start_col": 2, "start_line": 231 }
Prims.Tot
val bn_add_mod_n: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> lbignum t len
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0
val bn_add_mod_n: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> lbignum t len let bn_add_mod_n #t #len n a b =
false
null
false
let c0, res0 = bn_add a b in bn_reduce_once n c0 res0
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Base.carry", "Hacl.Spec.Bignum.bn_reduce_once", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.bn_add" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end
false
false
Hacl.Spec.Bignum.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_add_mod_n: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> lbignum t len
[]
Hacl.Spec.Bignum.bn_add_mod_n
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> b: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.lbignum t len
{ "end_col": 26, "end_line": 70, "start_col": 32, "start_line": 68 }
Prims.Tot
val bn_add1: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> carry t & lbignum t aLen
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1
val bn_add1: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> carry t & lbignum t aLen let bn_add1 #t #aLen a b1 =
false
null
false
Hacl.Spec.Bignum.Addition.bn_add1 a b1
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Addition.bn_add1", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Base.carry" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
false
Hacl.Spec.Bignum.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_add1: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> carry t & lbignum t aLen
[]
Hacl.Spec.Bignum.bn_add1
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b1: Hacl.Spec.Bignum.Definitions.limb t -> Hacl.Spec.Bignum.Base.carry t * Hacl.Spec.Bignum.Definitions.lbignum t aLen
{ "end_col": 40, "end_line": 9, "start_col": 2, "start_line": 9 }
Prims.Tot
val bn_mul: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{aLen + bLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t bLen -> lbignum t (aLen + bLen)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b
val bn_mul: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{aLen + bLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t bLen -> lbignum t (aLen + bLen) let bn_mul #t #aLen #bLen a b =
false
null
false
Hacl.Spec.Bignum.Multiplication.bn_mul a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Multiplication.bn_mul" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1
false
false
Hacl.Spec.Bignum.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_mul: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{aLen + bLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t bLen -> lbignum t (aLen + bLen)
[]
Hacl.Spec.Bignum.bn_mul
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.lbignum t bLen -> Hacl.Spec.Bignum.Definitions.lbignum t (aLen + bLen)
{ "end_col": 44, "end_line": 124, "start_col": 2, "start_line": 124 }
Prims.Tot
val bn_reduce_once: #t:limb_t -> #len:size_nat -> n:lbignum t len -> c:carry t -> a:lbignum t len -> lbignum t len
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res
val bn_reduce_once: #t:limb_t -> #len:size_nat -> n:lbignum t len -> c:carry t -> a:lbignum t len -> lbignum t len let bn_reduce_once #t #len n c0 a =
false
null
false
let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Base.carry", "Lib.Sequence.map2", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Base.mask_select", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Dot", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.bn_sub" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b
false
false
Hacl.Spec.Bignum.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_reduce_once: #t:limb_t -> #len:size_nat -> n:lbignum t len -> c:carry t -> a:lbignum t len -> lbignum t len
[]
Hacl.Spec.Bignum.bn_reduce_once
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> c: Hacl.Spec.Bignum.Base.carry t -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.lbignum t len
{ "end_col": 28, "end_line": 35, "start_col": 35, "start_line": 32 }
Prims.Tot
val bn_sqr: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> lbignum t (aLen + aLen)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a
val bn_sqr: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> lbignum t (aLen + aLen) let bn_sqr #t #aLen a =
false
null
false
Hacl.Spec.Bignum.Squaring.bn_sqr a
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Squaring.bn_sqr" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b
false
false
Hacl.Spec.Bignum.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_sqr: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> lbignum t (aLen + aLen)
[]
Hacl.Spec.Bignum.bn_sqr
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> Hacl.Spec.Bignum.Definitions.lbignum t (aLen + aLen)
{ "end_col": 36, "end_line": 136, "start_col": 2, "start_line": 136 }
Prims.Tot
val bn_sub1: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> carry t & lbignum t aLen
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1
val bn_sub1: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> carry t & lbignum t aLen let bn_sub1 #t #aLen a b1 =
false
null
false
Hacl.Spec.Bignum.Addition.bn_sub1 a b1
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Addition.bn_sub1", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Base.carry" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1
false
false
Hacl.Spec.Bignum.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_sub1: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> carry t & lbignum t aLen
[]
Hacl.Spec.Bignum.bn_sub1
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b1: Hacl.Spec.Bignum.Definitions.limb t -> Hacl.Spec.Bignum.Base.carry t * Hacl.Spec.Bignum.Definitions.lbignum t aLen
{ "end_col": 40, "end_line": 15, "start_col": 2, "start_line": 15 }
Prims.Tot
val bn_is_odd: #t:limb_t -> #len:size_pos -> a:lbignum t len -> limb t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b
val bn_is_odd: #t:limb_t -> #len:size_pos -> a:lbignum t len -> limb t let bn_is_odd #t #len b =
false
null
false
Hacl.Spec.Bignum.Comparison.bn_is_odd b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Comparison.bn_is_odd", "Hacl.Spec.Bignum.Definitions.limb" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *)
false
false
Hacl.Spec.Bignum.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_pos -> a:lbignum t len -> limb t
[]
Hacl.Spec.Bignum.bn_is_odd
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.limb t
{ "end_col": 41, "end_line": 213, "start_col": 2, "start_line": 213 }
Prims.Tot
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x
val bn_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len let bn_from_uint #t len x =
false
null
false
Hacl.Spec.Bignum.Convert.bn_from_uint len x
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Convert.bn_from_uint", "Hacl.Spec.Bignum.Definitions.lbignum" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *)
false
false
Hacl.Spec.Bignum.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_from_uint: #t:limb_t -> len:size_pos -> x:limb t -> lbignum t len
[]
Hacl.Spec.Bignum.bn_from_uint
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos -> x: Hacl.Spec.Bignum.Definitions.limb t -> Hacl.Spec.Bignum.Definitions.lbignum t len
{ "end_col": 45, "end_line": 251, "start_col": 2, "start_line": 251 }
Prims.Tot
val bn_karatsuba_sqr: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> lbignum t (aLen + aLen)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a
val bn_karatsuba_sqr: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> lbignum t (aLen + aLen) let bn_karatsuba_sqr #t #aLen a =
false
null
false
Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a
false
false
Hacl.Spec.Bignum.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_karatsuba_sqr: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> lbignum t (aLen + aLen)
[]
Hacl.Spec.Bignum.bn_karatsuba_sqr
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> Hacl.Spec.Bignum.Definitions.lbignum t (aLen + aLen)
{ "end_col": 47, "end_line": 142, "start_col": 2, "start_line": 142 }
Prims.Tot
val bn_rshift: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i < len} -> lbignum t (len - i)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i
val bn_rshift: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i < len} -> lbignum t (len - i) let bn_rshift #t #len b i =
false
null
false
Hacl.Spec.Bignum.Lib.bn_div_pow2 b i
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Lib.bn_div_pow2", "Prims.op_Subtraction" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc
false
false
Hacl.Spec.Bignum.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_rshift: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i < len} -> lbignum t (len - i)
[]
Hacl.Spec.Bignum.bn_rshift
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> i: Lib.IntTypes.size_nat{i < len} -> Hacl.Spec.Bignum.Definitions.lbignum t (len - i)
{ "end_col": 38, "end_line": 154, "start_col": 2, "start_line": 154 }
FStar.Pervasives.Lemma
val bn_is_zero_mask_lemma: #t:limb_t -> #len:size_nat -> a:lbignum t len -> Lemma (mask_values (bn_is_zero_mask a) /\ (if v (bn_is_zero_mask a) = 0 then bn_v a <> 0 else bn_v a = 0))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b
val bn_is_zero_mask_lemma: #t:limb_t -> #len:size_nat -> a:lbignum t len -> Lemma (mask_values (bn_is_zero_mask a) /\ (if v (bn_is_zero_mask a) = 0 then bn_v a <> 0 else bn_v a = 0)) let bn_is_zero_mask_lemma #t #len b =
false
null
true
Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b
false
false
Hacl.Spec.Bignum.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_lemma: #t:limb_t -> #len:size_nat -> a:lbignum t len -> Lemma (mask_values (bn_is_zero_mask a) /\ (if v (bn_is_zero_mask a) = 0 then bn_v a <> 0 else bn_v a = 0))
[]
Hacl.Spec.Bignum.bn_is_zero_mask_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t len -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Base.mask_values (Hacl.Spec.Bignum.bn_is_zero_mask a) /\ (match Lib.IntTypes.v (Hacl.Spec.Bignum.bn_is_zero_mask a) = 0 with | true -> Hacl.Spec.Bignum.Definitions.bn_v a <> 0 | _ -> Hacl.Spec.Bignum.Definitions.bn_v a = 0))
{ "end_col": 53, "end_line": 228, "start_col": 2, "start_line": 228 }
FStar.Pervasives.Lemma
val bn_lt_mask_lemma: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> Lemma (mask_values (bn_lt_mask a b) /\ (if v (bn_lt_mask a b) = 0 then bn_v a >= bn_v b else bn_v a < bn_v b))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b
val bn_lt_mask_lemma: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> Lemma (mask_values (bn_lt_mask a b) /\ (if v (bn_lt_mask a b) = 0 then bn_v a >= bn_v b else bn_v a < bn_v b)) let bn_lt_mask_lemma #t #len a b =
false
null
true
Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b
false
false
Hacl.Spec.Bignum.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_lemma: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> Lemma (mask_values (bn_lt_mask a b) /\ (if v (bn_lt_mask a b) = 0 then bn_v a >= bn_v b else bn_v a < bn_v b))
[]
Hacl.Spec.Bignum.bn_lt_mask_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t len -> b: Hacl.Spec.Bignum.Definitions.lbignum t len -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Base.mask_values (Hacl.Spec.Bignum.bn_lt_mask a b) /\ (match Lib.IntTypes.v (Hacl.Spec.Bignum.bn_lt_mask a b) = 0 with | true -> Hacl.Spec.Bignum.Definitions.bn_v a >= Hacl.Spec.Bignum.Definitions.bn_v b | _ -> Hacl.Spec.Bignum.Definitions.bn_v a < Hacl.Spec.Bignum.Definitions.bn_v b))
{ "end_col": 50, "end_line": 234, "start_col": 2, "start_line": 234 }
FStar.Pervasives.Lemma
val bn_lt_pow2_mask_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> Lemma (mask_values (bn_lt_pow2_mask b x) /\ (if v (bn_lt_pow2_mask b x) = 0 then bn_v b >= pow2 x else bn_v b < pow2 x))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x
val bn_lt_pow2_mask_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> Lemma (mask_values (bn_lt_pow2_mask b x) /\ (if v (bn_lt_pow2_mask b x) = 0 then bn_v b >= pow2 x else bn_v b < pow2 x)) let bn_lt_pow2_mask_lemma #t #len b x =
false
null
true
Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x
false
false
Hacl.Spec.Bignum.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_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> Lemma (mask_values (bn_lt_pow2_mask b x) /\ (if v (bn_lt_pow2_mask b x) = 0 then bn_v b >= pow2 x else bn_v b < pow2 x))
[]
Hacl.Spec.Bignum.bn_lt_pow2_mask_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> x: Lib.IntTypes.size_nat{x < Lib.IntTypes.bits t * len} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Base.mask_values (Hacl.Spec.Bignum.bn_lt_pow2_mask b x) /\ (match Lib.IntTypes.v (Hacl.Spec.Bignum.bn_lt_pow2_mask b x) = 0 with | true -> Hacl.Spec.Bignum.Definitions.bn_v b >= Prims.pow2 x | _ -> Hacl.Spec.Bignum.Definitions.bn_v b < Prims.pow2 x))
{ "end_col": 55, "end_line": 240, "start_col": 2, "start_line": 240 }
FStar.Pervasives.Lemma
val bn_karatsuba_sqr_lemma: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> Lemma (bn_karatsuba_sqr a == bn_mul a a /\ bn_v (bn_karatsuba_sqr a) == bn_v a * bn_v a)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a
val bn_karatsuba_sqr_lemma: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> Lemma (bn_karatsuba_sqr a == bn_mul a a /\ bn_v (bn_karatsuba_sqr a) == bn_v a * bn_v a) let bn_karatsuba_sqr_lemma #t #aLen a =
false
null
true
Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a
false
false
Hacl.Spec.Bignum.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_karatsuba_sqr_lemma: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> Lemma (bn_karatsuba_sqr a == bn_mul a a /\ bn_v (bn_karatsuba_sqr a) == bn_v a * bn_v a)
[]
Hacl.Spec.Bignum.bn_karatsuba_sqr_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.bn_karatsuba_sqr a == Hacl.Spec.Bignum.bn_mul a a /\ Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_karatsuba_sqr a) == Hacl.Spec.Bignum.Definitions.bn_v a * Hacl.Spec.Bignum.Definitions.bn_v a)
{ "end_col": 53, "end_line": 145, "start_col": 2, "start_line": 145 }
FStar.Pervasives.Lemma
val bn_gt_pow2_mask_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> Lemma (mask_values (bn_gt_pow2_mask b x) /\ (if v (bn_gt_pow2_mask b x) = 0 then pow2 x >= bn_v b else pow2 x < bn_v b))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x
val bn_gt_pow2_mask_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> Lemma (mask_values (bn_gt_pow2_mask b x) /\ (if v (bn_gt_pow2_mask b x) = 0 then pow2 x >= bn_v b else pow2 x < bn_v b)) let bn_gt_pow2_mask_lemma #t #len b x =
false
null
true
Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x
false
false
Hacl.Spec.Bignum.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_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> x:size_nat{x < bits t * len} -> Lemma (mask_values (bn_gt_pow2_mask b x) /\ (if v (bn_gt_pow2_mask b x) = 0 then pow2 x >= bn_v b else pow2 x < bn_v b))
[]
Hacl.Spec.Bignum.bn_gt_pow2_mask_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> x: Lib.IntTypes.size_nat{x < Lib.IntTypes.bits t * len} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Base.mask_values (Hacl.Spec.Bignum.bn_gt_pow2_mask b x) /\ (match Lib.IntTypes.v (Hacl.Spec.Bignum.bn_gt_pow2_mask b x) = 0 with | true -> Prims.pow2 x >= Hacl.Spec.Bignum.Definitions.bn_v b | _ -> Prims.pow2 x < Hacl.Spec.Bignum.Definitions.bn_v b))
{ "end_col": 55, "end_line": 246, "start_col": 2, "start_line": 246 }
Prims.Tot
val bn_get_bits: #t:limb_t -> #nLen:size_nat -> n:lbignum t nLen -> i:size_nat -> l:size_nat{l < bits t /\ i / bits t < nLen} -> limb t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l
val bn_get_bits: #t:limb_t -> #nLen:size_nat -> n:lbignum t nLen -> i:size_nat -> l:size_nat{l < bits t /\ i / bits t < nLen} -> limb t let bn_get_bits #t #nLen n i l =
false
null
false
Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.bits", "Prims.op_Division", "Hacl.Spec.Bignum.Lib.bn_get_bits", "Hacl.Spec.Bignum.Definitions.limb" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind
false
false
Hacl.Spec.Bignum.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_get_bits: #t:limb_t -> #nLen:size_nat -> n:lbignum t nLen -> i:size_nat -> l:size_nat{l < bits t /\ i / bits t < nLen} -> limb t
[]
Hacl.Spec.Bignum.bn_get_bits
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t nLen -> i: Lib.IntTypes.size_nat -> l: Lib.IntTypes.size_nat{l < Lib.IntTypes.bits t /\ i / Lib.IntTypes.bits t < nLen} -> Hacl.Spec.Bignum.Definitions.limb t
{ "end_col": 49, "end_line": 191, "start_col": 2, "start_line": 191 }
Prims.Tot
val bn_set_ith_bit: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> lbignum t len
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind
val bn_set_ith_bit: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> lbignum t len let bn_set_ith_bit #t #len input ind =
false
null
false
Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Lib.bn_set_ith_bit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l
false
false
Hacl.Spec.Bignum.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_set_ith_bit: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> lbignum t len
[]
Hacl.Spec.Bignum.bn_set_ith_bit
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> i: Lib.IntTypes.size_nat{i / Lib.IntTypes.bits t < len} -> Hacl.Spec.Bignum.Definitions.lbignum t len
{ "end_col": 47, "end_line": 197, "start_col": 2, "start_line": 197 }
FStar.Pervasives.Lemma
val bn_eq_mask_lemma: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> Lemma (mask_values (bn_eq_mask a b) /\ (if v (bn_eq_mask a b) = 0 then bn_v a <> bn_v b else bn_v a = bn_v b))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b
val bn_eq_mask_lemma: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> Lemma (mask_values (bn_eq_mask a b) /\ (if v (bn_eq_mask a b) = 0 then bn_v a <> bn_v b else bn_v a = bn_v b)) let bn_eq_mask_lemma #t #len a b =
false
null
true
Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b
false
false
Hacl.Spec.Bignum.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_lemma: #t:limb_t -> #len:size_nat -> a:lbignum t len -> b:lbignum t len -> Lemma (mask_values (bn_eq_mask a b) /\ (if v (bn_eq_mask a b) = 0 then bn_v a <> bn_v b else bn_v a = bn_v b))
[]
Hacl.Spec.Bignum.bn_eq_mask_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t len -> b: Hacl.Spec.Bignum.Definitions.lbignum t len -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Base.mask_values (Hacl.Spec.Bignum.bn_eq_mask a b) /\ (match Lib.IntTypes.v (Hacl.Spec.Bignum.bn_eq_mask a b) = 0 with | true -> Hacl.Spec.Bignum.Definitions.bn_v a <> Hacl.Spec.Bignum.Definitions.bn_v b | _ -> Hacl.Spec.Bignum.Definitions.bn_v a = Hacl.Spec.Bignum.Definitions.bn_v b))
{ "end_col": 50, "end_line": 222, "start_col": 2, "start_line": 222 }
Prims.Tot
val bn_get_ith_bit: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> limb t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind
val bn_get_ith_bit: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> limb t let bn_get_ith_bit #t #len input ind =
false
null
false
Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Lib.bn_get_ith_bit", "Hacl.Spec.Bignum.Definitions.limb" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *)
false
false
Hacl.Spec.Bignum.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_get_ith_bit: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> limb t
[]
Hacl.Spec.Bignum.bn_get_ith_bit
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> i: Lib.IntTypes.size_nat{i / Lib.IntTypes.bits t < len} -> Hacl.Spec.Bignum.Definitions.limb t
{ "end_col": 47, "end_line": 185, "start_col": 2, "start_line": 185 }
FStar.Pervasives.Lemma
val bn_sub_lemma: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> Lemma (let (c_out, res) = bn_sub a b in bn_v res - v c_out * pow2 (bits t * aLen) == bn_v a - bn_v b)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b
val bn_sub_lemma: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> Lemma (let (c_out, res) = bn_sub a b in bn_v res - v c_out * pow2 (bits t * aLen) == bn_v a - bn_v b) let bn_sub_lemma #t #aLen #bLen a b =
false
null
true
Hacl.Spec.Bignum.Addition.bn_sub_lemma a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Addition.bn_sub_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b
false
false
Hacl.Spec.Bignum.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_sub_lemma: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> Lemma (let (c_out, res) = bn_sub a b in bn_v res - v c_out * pow2 (bits t * aLen) == bn_v a - bn_v b)
[]
Hacl.Spec.Bignum.bn_sub_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.lbignum t bLen -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Bignum.bn_sub a b in (let FStar.Pervasives.Native.Mktuple2 #_ #_ c_out res = _ in Hacl.Spec.Bignum.Definitions.bn_v res - Lib.IntTypes.v c_out * Prims.pow2 (Lib.IntTypes.bits t * aLen) == Hacl.Spec.Bignum.Definitions.bn_v a - Hacl.Spec.Bignum.Definitions.bn_v b) <: Type0))
{ "end_col": 44, "end_line": 30, "start_col": 2, "start_line": 30 }
FStar.Pervasives.Lemma
val bn_karatsuba_mul_lemma: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t aLen -> Lemma (bn_karatsuba_mul a b == bn_mul a b /\ bn_v (bn_karatsuba_mul a b) == bn_v a * bn_v b)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b
val bn_karatsuba_mul_lemma: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t aLen -> Lemma (bn_karatsuba_mul a b == bn_mul a b /\ bn_v (bn_karatsuba_mul a b) == bn_v a * bn_v b) let bn_karatsuba_mul_lemma #t #aLen a b =
false
null
true
Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b
false
false
Hacl.Spec.Bignum.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_karatsuba_mul_lemma: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t aLen -> Lemma (bn_karatsuba_mul a b == bn_mul a b /\ bn_v (bn_karatsuba_mul a b) == bn_v a * bn_v b)
[]
Hacl.Spec.Bignum.bn_karatsuba_mul_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.bn_karatsuba_mul a b == Hacl.Spec.Bignum.bn_mul a b /\ Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_karatsuba_mul a b) == Hacl.Spec.Bignum.Definitions.bn_v a * Hacl.Spec.Bignum.Definitions.bn_v b)
{ "end_col": 55, "end_line": 133, "start_col": 2, "start_line": 133 }
FStar.Pervasives.Lemma
val bn_mul1_lemma: #t:limb_t -> #aLen:size_nat -> a:lbignum t aLen -> b1:limb t -> Lemma (let (c, res) = bn_mul1 a b1 in v c * pow2 (bits t * aLen) + bn_v res == bn_v a * v b1)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1
val bn_mul1_lemma: #t:limb_t -> #aLen:size_nat -> a:lbignum t aLen -> b1:limb t -> Lemma (let (c, res) = bn_mul1 a b1 in v c * pow2 (bits t * aLen) + bn_v res == bn_v a * v b1) let bn_mul1_lemma #t #aLen a b1 =
false
null
true
Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1
false
false
Hacl.Spec.Bignum.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_mul1_lemma: #t:limb_t -> #aLen:size_nat -> a:lbignum t aLen -> b1:limb t -> Lemma (let (c, res) = bn_mul1 a b1 in v c * pow2 (bits t * aLen) + bn_v res == bn_v a * v b1)
[]
Hacl.Spec.Bignum.bn_mul1_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b1: Hacl.Spec.Bignum.Definitions.limb t -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Bignum.bn_mul1 a b1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ c res = _ in Lib.IntTypes.v c * Prims.pow2 (Lib.IntTypes.bits t * aLen) + Hacl.Spec.Bignum.Definitions.bn_v res == Hacl.Spec.Bignum.Definitions.bn_v a * Lib.IntTypes.v b1) <: Type0))
{ "end_col": 52, "end_line": 121, "start_col": 2, "start_line": 121 }
FStar.Pervasives.Lemma
val bn_add_lemma: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> Lemma (let (c_out, res) = bn_add a b in bn_v res + v c_out * pow2 (bits t * aLen) == bn_v a + bn_v b)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b
val bn_add_lemma: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> Lemma (let (c_out, res) = bn_add a b in bn_v res + v c_out * pow2 (bits t * aLen) == bn_v a + bn_v b) let bn_add_lemma #t #aLen #bLen a b =
false
null
true
Hacl.Spec.Bignum.Addition.bn_add_lemma a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Addition.bn_add_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b
false
false
Hacl.Spec.Bignum.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_add_lemma: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{bLen <= aLen} -> a:lbignum t aLen -> b:lbignum t bLen -> Lemma (let (c_out, res) = bn_add a b in bn_v res + v c_out * pow2 (bits t * aLen) == bn_v a + bn_v b)
[]
Hacl.Spec.Bignum.bn_add_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.lbignum t bLen -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Bignum.bn_add a b in (let FStar.Pervasives.Native.Mktuple2 #_ #_ c_out res = _ in Hacl.Spec.Bignum.Definitions.bn_v res + Lib.IntTypes.v c_out * Prims.pow2 (Lib.IntTypes.bits t * aLen) == Hacl.Spec.Bignum.Definitions.bn_v a + Hacl.Spec.Bignum.Definitions.bn_v b) <: Type0))
{ "end_col": 44, "end_line": 24, "start_col": 2, "start_line": 24 }
FStar.Pervasives.Lemma
val bn_set_ith_bit_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> Lemma (requires bn_v b < pow2 i) (ensures bn_v (bn_set_ith_bit b i) == bn_v b + pow2 i)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind
val bn_set_ith_bit_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> Lemma (requires bn_v b < pow2 i) (ensures bn_v (bn_set_ith_bit b i) == bn_v b + pow2 i) let bn_set_ith_bit_lemma #t #len input ind =
false
null
true
Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind
false
false
Hacl.Spec.Bignum.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_set_ith_bit_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> Lemma (requires bn_v b < pow2 i) (ensures bn_v (bn_set_ith_bit b i) == bn_v b + pow2 i)
[]
Hacl.Spec.Bignum.bn_set_ith_bit_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> i: Lib.IntTypes.size_nat{i / Lib.IntTypes.bits t < len} -> FStar.Pervasives.Lemma (requires Hacl.Spec.Bignum.Definitions.bn_v b < Prims.pow2 i) (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_set_ith_bit b i) == Hacl.Spec.Bignum.Definitions.bn_v b + Prims.pow2 i)
{ "end_col": 53, "end_line": 200, "start_col": 2, "start_line": 200 }
FStar.Pervasives.Lemma
val bn_add_mod_n_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> Lemma (requires bn_v a < bn_v n /\ bn_v b < bn_v n) (ensures bn_v (bn_add_mod_n n a b) == (bn_v a + bn_v b) % bn_v n)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0
val bn_add_mod_n_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> Lemma (requires bn_v a < bn_v n /\ bn_v b < bn_v n) (ensures bn_v (bn_add_mod_n n a b) == (bn_v a + bn_v b) % bn_v n) let bn_add_mod_n_lemma #t #len n a b =
false
null
true
let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Base.carry", "Hacl.Spec.Bignum.bn_reduce_once_lemma", "Prims.unit", "Hacl.Spec.Bignum.bn_add_lemma", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.bn_add" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0
false
false
Hacl.Spec.Bignum.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_add_mod_n_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> Lemma (requires bn_v a < bn_v n /\ bn_v b < bn_v n) (ensures bn_v (bn_add_mod_n n a b) == (bn_v a + bn_v b) % bn_v n)
[]
Hacl.Spec.Bignum.bn_add_mod_n_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> b: Hacl.Spec.Bignum.Definitions.lbignum t len -> FStar.Pervasives.Lemma (requires Hacl.Spec.Bignum.Definitions.bn_v a < Hacl.Spec.Bignum.Definitions.bn_v n /\ Hacl.Spec.Bignum.Definitions.bn_v b < Hacl.Spec.Bignum.Definitions.bn_v n) (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_add_mod_n n a b) == (Hacl.Spec.Bignum.Definitions.bn_v a + Hacl.Spec.Bignum.Definitions.bn_v b) % Hacl.Spec.Bignum.Definitions.bn_v n)
{ "end_col": 32, "end_line": 76, "start_col": 38, "start_line": 73 }
FStar.Pervasives.Lemma
val cswap2_lemma: #t:limb_t -> #len:size_nat -> bit:limb t{v bit <= 1} -> b1:lbignum t len -> b2:lbignum t len -> Lemma (let (p1, p2) = cswap2 bit b1 b2 in (if v bit = 1 then p1 == b2 /\ p2 == b1 else p1 == b1 /\ p2 == b2))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2
val cswap2_lemma: #t:limb_t -> #len:size_nat -> bit:limb t{v bit <= 1} -> b1:lbignum t len -> b2:lbignum t len -> Lemma (let (p1, p2) = cswap2 bit b1 b2 in (if v bit = 1 then p1 == b2 /\ p2 == b1 else p1 == b1 /\ p2 == b2)) let cswap2_lemma #t #len bit b1 b2 =
false
null
true
Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.limb", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Lib.cswap2_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2
false
false
Hacl.Spec.Bignum.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 cswap2_lemma: #t:limb_t -> #len:size_nat -> bit:limb t{v bit <= 1} -> b1:lbignum t len -> b2:lbignum t len -> Lemma (let (p1, p2) = cswap2 bit b1 b2 in (if v bit = 1 then p1 == b2 /\ p2 == b1 else p1 == b1 /\ p2 == b2))
[]
Hacl.Spec.Bignum.cswap2_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bit: Hacl.Spec.Bignum.Definitions.limb t {Lib.IntTypes.v bit <= 1} -> b1: Hacl.Spec.Bignum.Definitions.lbignum t len -> b2: Hacl.Spec.Bignum.Definitions.lbignum t len -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Bignum.cswap2 bit b1 b2 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ p1 p2 = _ in (match Lib.IntTypes.v bit = 1 with | true -> p1 == b2 /\ p2 == b1 | _ -> p1 == b1 /\ p2 == b2) <: Type0) <: Type0))
{ "end_col": 45, "end_line": 208, "start_col": 2, "start_line": 208 }
FStar.Pervasives.Lemma
val bn_rshift_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i < len} -> Lemma (bn_v (bn_rshift b i) == bn_v b / pow2 (bits t * i))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i
val bn_rshift_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i < len} -> Lemma (bn_v (bn_rshift b i) == bn_v b / pow2 (bits t * i)) let bn_rshift_lemma #t #len c i =
false
null
true
Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i
false
false
Hacl.Spec.Bignum.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_rshift_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i < len} -> Lemma (bn_v (bn_rshift b i) == bn_v b / pow2 (bits t * i))
[]
Hacl.Spec.Bignum.bn_rshift_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> i: Lib.IntTypes.size_nat{i < len} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_rshift b i) == Hacl.Spec.Bignum.Definitions.bn_v b / Prims.pow2 (Lib.IntTypes.bits t * i))
{ "end_col": 44, "end_line": 157, "start_col": 2, "start_line": 157 }
FStar.Pervasives.Lemma
val bn_sub1_lemma: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> Lemma (let (c, res) = bn_sub1 a b1 in bn_v res - v c * pow2 (bits t * aLen) == bn_v a - v b1)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1
val bn_sub1_lemma: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> Lemma (let (c, res) = bn_sub1 a b1 in bn_v res - v c * pow2 (bits t * aLen) == bn_v a - v b1) let bn_sub1_lemma #t #aLen a b1 =
false
null
true
Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Addition.bn_sub1_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1
false
false
Hacl.Spec.Bignum.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_sub1_lemma: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> Lemma (let (c, res) = bn_sub1 a b1 in bn_v res - v c * pow2 (bits t * aLen) == bn_v a - v b1)
[]
Hacl.Spec.Bignum.bn_sub1_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b1: Hacl.Spec.Bignum.Definitions.limb t -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Bignum.bn_sub1 a b1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ c res = _ in Hacl.Spec.Bignum.Definitions.bn_v res - Lib.IntTypes.v c * Prims.pow2 (Lib.IntTypes.bits t * aLen) == Hacl.Spec.Bignum.Definitions.bn_v a - Lib.IntTypes.v b1) <: Type0))
{ "end_col": 46, "end_line": 18, "start_col": 2, "start_line": 18 }
FStar.Pervasives.Lemma
val bn_add1_lemma: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> Lemma (let (c, res) = bn_add1 a b1 in v c * pow2 (bits t * aLen) + bn_v res == bn_v a + v b1)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1
val bn_add1_lemma: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> Lemma (let (c, res) = bn_add1 a b1 in v c * pow2 (bits t * aLen) + bn_v res == bn_v a + v b1) let bn_add1_lemma #t #aLen a b1 =
false
null
true
Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Addition.bn_add1_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1
false
false
Hacl.Spec.Bignum.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_add1_lemma: #t:limb_t -> #aLen:size_pos -> a:lbignum t aLen -> b1:limb t -> Lemma (let (c, res) = bn_add1 a b1 in v c * pow2 (bits t * aLen) + bn_v res == bn_v a + v b1)
[]
Hacl.Spec.Bignum.bn_add1_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b1: Hacl.Spec.Bignum.Definitions.limb t -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Bignum.bn_add1 a b1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ c res = _ in Lib.IntTypes.v c * Prims.pow2 (Lib.IntTypes.bits t * aLen) + Hacl.Spec.Bignum.Definitions.bn_v res == Hacl.Spec.Bignum.Definitions.bn_v a + Lib.IntTypes.v b1) <: Type0))
{ "end_col": 46, "end_line": 12, "start_col": 2, "start_line": 12 }
Prims.Tot
val bn_from_bytes_le: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> lbignum t (blocks len (numbytes t))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_from_bytes_le #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le #t len b
val bn_from_bytes_le: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> lbignum t (blocks len (numbytes t)) let bn_from_bytes_le #t len b =
false
null
false
Hacl.Spec.Bignum.Convert.bn_from_bytes_le #t len b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.max_size_t", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "Hacl.Spec.Bignum.Convert.bn_from_bytes_le", "Hacl.Spec.Bignum.Definitions.lbignum" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *) let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x let bn_from_uint_lemma #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x let bn_from_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b let bn_from_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #t len b
false
false
Hacl.Spec.Bignum.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_from_bytes_le: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> lbignum t (blocks len (numbytes t))
[]
Hacl.Spec.Bignum.bn_from_bytes_le
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos { Lib.IntTypes.numbytes t * Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <= Lib.IntTypes.max_size_t } -> b: Lib.Sequence.lseq Lib.IntTypes.uint8 len -> Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t))
{ "end_col": 52, "end_line": 263, "start_col": 2, "start_line": 263 }
FStar.Pervasives.Lemma
val bn_get_bits_lemma: #t:limb_t -> #nLen:size_nat -> n:lbignum t nLen -> i:size_nat -> l:size_nat{l < bits t /\ i / bits t < nLen} -> Lemma (v (bn_get_bits n i l) == (bn_v n / pow2 i) % pow2 l)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l
val bn_get_bits_lemma: #t:limb_t -> #nLen:size_nat -> n:lbignum t nLen -> i:size_nat -> l:size_nat{l < bits t /\ i / bits t < nLen} -> Lemma (v (bn_get_bits n i l) == (bn_v n / pow2 i) % pow2 l) let bn_get_bits_lemma #t #nLen n i l =
false
null
true
Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.bits", "Prims.op_Division", "Hacl.Spec.Bignum.Lib.bn_get_bits_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l
false
false
Hacl.Spec.Bignum.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_get_bits_lemma: #t:limb_t -> #nLen:size_nat -> n:lbignum t nLen -> i:size_nat -> l:size_nat{l < bits t /\ i / bits t < nLen} -> Lemma (v (bn_get_bits n i l) == (bn_v n / pow2 i) % pow2 l)
[]
Hacl.Spec.Bignum.bn_get_bits_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t nLen -> i: Lib.IntTypes.size_nat -> l: Lib.IntTypes.size_nat{l < Lib.IntTypes.bits t /\ i / Lib.IntTypes.bits t < nLen} -> FStar.Pervasives.Lemma (ensures Lib.IntTypes.v (Hacl.Spec.Bignum.bn_get_bits n i l) == Hacl.Spec.Bignum.Definitions.bn_v n / Prims.pow2 i % Prims.pow2 l)
{ "end_col": 55, "end_line": 194, "start_col": 2, "start_line": 194 }
Prims.Tot
val bn_to_bytes_le: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)) -> lseq uint8 len
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_to_bytes_le #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_le len b
val bn_to_bytes_le: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)) -> lseq uint8 len let bn_to_bytes_le #t len b =
false
null
false
Hacl.Spec.Bignum.Convert.bn_to_bytes_le len b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Convert.bn_to_bytes_le", "Lib.Sequence.lseq", "Lib.IntTypes.uint8" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *) let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x let bn_from_uint_lemma #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x let bn_from_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b let bn_from_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #t len b let bn_from_bytes_le #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le #t len b let bn_from_bytes_le_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma #t len b let bn_to_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_be len b let bn_to_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma len b
false
false
Hacl.Spec.Bignum.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_to_bytes_le: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)) -> lseq uint8 len
[]
Hacl.Spec.Bignum.bn_to_bytes_le
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos { Lib.IntTypes.numbytes t * Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <= Lib.IntTypes.max_size_t } -> b: Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t)) -> Lib.Sequence.lseq Lib.IntTypes.uint8 len
{ "end_col": 47, "end_line": 275, "start_col": 2, "start_line": 275 }
Prims.Tot
val bn_from_bytes_be: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> lbignum t (blocks len (numbytes t))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_from_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b
val bn_from_bytes_be: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> lbignum t (blocks len (numbytes t)) let bn_from_bytes_be #t len b =
false
null
false
Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.max_size_t", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "Hacl.Spec.Bignum.Convert.bn_from_bytes_be", "Hacl.Spec.Bignum.Definitions.lbignum" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *) let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x let bn_from_uint_lemma #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x
false
false
Hacl.Spec.Bignum.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_from_bytes_be: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> lbignum t (blocks len (numbytes t))
[]
Hacl.Spec.Bignum.bn_from_bytes_be
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos { Lib.IntTypes.numbytes t * Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <= Lib.IntTypes.max_size_t } -> b: Lib.Sequence.lseq Lib.IntTypes.uint8 len -> Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t))
{ "end_col": 49, "end_line": 257, "start_col": 2, "start_line": 257 }
Prims.Tot
val bn_to_bytes_be: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)) -> lseq uint8 len
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_to_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_be len b
val bn_to_bytes_be: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)) -> lseq uint8 len let bn_to_bytes_be #t len b =
false
null
false
Hacl.Spec.Bignum.Convert.bn_to_bytes_be len b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Convert.bn_to_bytes_be", "Lib.Sequence.lseq", "Lib.IntTypes.uint8" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *) let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x let bn_from_uint_lemma #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x let bn_from_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b let bn_from_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #t len b let bn_from_bytes_le #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le #t len b let bn_from_bytes_le_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma #t len b
false
false
Hacl.Spec.Bignum.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_to_bytes_be: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)) -> lseq uint8 len
[]
Hacl.Spec.Bignum.bn_to_bytes_be
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos { Lib.IntTypes.numbytes t * Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <= Lib.IntTypes.max_size_t } -> b: Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t)) -> Lib.Sequence.lseq Lib.IntTypes.uint8 len
{ "end_col": 47, "end_line": 269, "start_col": 2, "start_line": 269 }
FStar.Pervasives.Lemma
val bn_from_bytes_le_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> Lemma (bn_v (bn_from_bytes_le #t len b) == BSeq.nat_from_bytes_le b)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_from_bytes_le_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma #t len b
val bn_from_bytes_le_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> Lemma (bn_v (bn_from_bytes_le #t len b) == BSeq.nat_from_bytes_le b) let bn_from_bytes_le_lemma #t len b =
false
null
true
Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma #t len b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.max_size_t", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *) let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x let bn_from_uint_lemma #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x let bn_from_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b let bn_from_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #t len b let bn_from_bytes_le #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le #t len b
false
false
Hacl.Spec.Bignum.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_from_bytes_le_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> Lemma (bn_v (bn_from_bytes_le #t len b) == BSeq.nat_from_bytes_le b)
[]
Hacl.Spec.Bignum.bn_from_bytes_le_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos { Lib.IntTypes.numbytes t * Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <= Lib.IntTypes.max_size_t } -> b: Lib.Sequence.lseq Lib.IntTypes.uint8 len -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_from_bytes_le len b) == Lib.ByteSequence.nat_from_bytes_le b)
{ "end_col": 58, "end_line": 266, "start_col": 2, "start_line": 266 }
FStar.Pervasives.Lemma
val bn_from_bytes_be_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> Lemma (bn_v (bn_from_bytes_be #t len b) == BSeq.nat_from_bytes_be b)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_from_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #t len b
val bn_from_bytes_be_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> Lemma (bn_v (bn_from_bytes_be #t len b) == BSeq.nat_from_bytes_be b) let bn_from_bytes_be_lemma #t len b =
false
null
true
Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #t len b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.max_size_t", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *) let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x let bn_from_uint_lemma #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x let bn_from_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b
false
false
Hacl.Spec.Bignum.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_from_bytes_be_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lseq uint8 len -> Lemma (bn_v (bn_from_bytes_be #t len b) == BSeq.nat_from_bytes_be b)
[]
Hacl.Spec.Bignum.bn_from_bytes_be_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos { Lib.IntTypes.numbytes t * Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <= Lib.IntTypes.max_size_t } -> b: Lib.Sequence.lseq Lib.IntTypes.uint8 len -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_from_bytes_be len b) == Lib.ByteSequence.nat_from_bytes_be b)
{ "end_col": 58, "end_line": 260, "start_col": 2, "start_line": 260 }
Prims.Tot
val bn_sub_mask: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> lbignum t len
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res
val bn_sub_mask: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> lbignum t len let bn_sub_mask #t #len n a =
false
null
false
let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Base.carry", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Addition.bn_sub", "Lib.Sequence.lseq", "Hacl.Spec.Bignum.Definitions.limb", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Lib.Sequence.index", "Lib.IntTypes.logand", "Lib.IntTypes.SEC", "Lib.Sequence.map", "Lib.IntTypes.int_t", "Prims.l_and", "Prims.l_or", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.sub", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.v", "Lib.IntTypes.ones", "Prims.l_not", "Lib.IntTypes.zeros", "Lib.ByteSequence.seq_eq_mask" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i
false
false
Hacl.Spec.Bignum.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_sub_mask: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> lbignum t len
[]
Hacl.Spec.Bignum.bn_sub_mask
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.lbignum t len
{ "end_col": 5, "end_line": 163, "start_col": 29, "start_line": 159 }
FStar.Pervasives.Lemma
val bn_mul1_lshift_add_lemma: #t:limb_t -> #aLen:size_nat -> #resLen:size_nat -> a:lbignum t aLen -> b:limb t -> j:size_nat{j + aLen <= resLen} -> acc:lbignum t resLen -> Lemma (let (c_out, res) = bn_mul1_lshift_add a b j acc in v c_out * pow2 (bits t * (aLen + j)) + eval_ resLen res (aLen + j) == eval_ resLen acc (aLen + j) + bn_v a * v b * pow2 (bits t * j) /\ slice res (aLen + j) resLen == slice acc (aLen + j) resLen)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc
val bn_mul1_lshift_add_lemma: #t:limb_t -> #aLen:size_nat -> #resLen:size_nat -> a:lbignum t aLen -> b:limb t -> j:size_nat{j + aLen <= resLen} -> acc:lbignum t resLen -> Lemma (let (c_out, res) = bn_mul1_lshift_add a b j acc in v c_out * pow2 (bits t * (aLen + j)) + eval_ resLen res (aLen + j) == eval_ resLen acc (aLen + j) + bn_v a * v b * pow2 (bits t * j) /\ slice res (aLen + j) resLen == slice acc (aLen + j) resLen) let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc =
false
null
true
Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc
false
false
Hacl.Spec.Bignum.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_mul1_lshift_add_lemma: #t:limb_t -> #aLen:size_nat -> #resLen:size_nat -> a:lbignum t aLen -> b:limb t -> j:size_nat{j + aLen <= resLen} -> acc:lbignum t resLen -> Lemma (let (c_out, res) = bn_mul1_lshift_add a b j acc in v c_out * pow2 (bits t * (aLen + j)) + eval_ resLen res (aLen + j) == eval_ resLen acc (aLen + j) + bn_v a * v b * pow2 (bits t * j) /\ slice res (aLen + j) resLen == slice acc (aLen + j) resLen)
[]
Hacl.Spec.Bignum.bn_mul1_lshift_add_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.limb t -> j: Lib.IntTypes.size_nat{j + aLen <= resLen} -> acc: Hacl.Spec.Bignum.Definitions.lbignum t resLen -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Bignum.bn_mul1_lshift_add a b j acc in (let FStar.Pervasives.Native.Mktuple2 #_ #_ c_out res = _ in Lib.IntTypes.v c_out * Prims.pow2 (Lib.IntTypes.bits t * (aLen + j)) + Hacl.Spec.Bignum.Definitions.eval_ resLen res (aLen + j) == Hacl.Spec.Bignum.Definitions.eval_ resLen acc (aLen + j) + (Hacl.Spec.Bignum.Definitions.bn_v a * Lib.IntTypes.v b) * Prims.pow2 (Lib.IntTypes.bits t * j) /\ Lib.Sequence.slice res (aLen + j) resLen == Lib.Sequence.slice acc (aLen + j) resLen) <: Type0))
{ "end_col": 68, "end_line": 151, "start_col": 2, "start_line": 151 }
FStar.Pervasives.Lemma
val bn_to_bytes_le_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} -> Lemma (bn_to_bytes_le len b == BSeq.nat_to_intseq_le #U8 len (bn_v b))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_to_bytes_le_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_le_lemma len b
val bn_to_bytes_le_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} -> Lemma (bn_to_bytes_le len b == BSeq.nat_to_intseq_le #U8 len (bn_v b)) let bn_to_bytes_le_lemma #t len b =
false
null
true
Hacl.Spec.Bignum.Convert.bn_to_bytes_le_lemma len b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.pow2", "Hacl.Spec.Bignum.Convert.bn_to_bytes_le_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *) let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x let bn_from_uint_lemma #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x let bn_from_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b let bn_from_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #t len b let bn_from_bytes_le #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le #t len b let bn_from_bytes_le_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma #t len b let bn_to_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_be len b let bn_to_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma len b let bn_to_bytes_le #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_le len b
false
false
Hacl.Spec.Bignum.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_to_bytes_le_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} -> Lemma (bn_to_bytes_le len b == BSeq.nat_to_intseq_le #U8 len (bn_v b))
[]
Hacl.Spec.Bignum.bn_to_bytes_le_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos { Lib.IntTypes.numbytes t * Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <= Lib.IntTypes.max_size_t } -> b: Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t)) {Hacl.Spec.Bignum.Definitions.bn_v b < Prims.pow2 (8 * len)} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.bn_to_bytes_le len b == Lib.ByteSequence.nat_to_intseq_le len (Hacl.Spec.Bignum.Definitions.bn_v b))
{ "end_col": 53, "end_line": 278, "start_col": 2, "start_line": 278 }
FStar.Pervasives.Lemma
val bn_sub_mod_n_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> Lemma (requires bn_v a < bn_v n /\ bn_v b < bn_v n) (ensures bn_v (bn_sub_mod_n n a b) == (bn_v a - bn_v b) % bn_v n)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end
val bn_sub_mod_n_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> Lemma (requires bn_v a < bn_v n /\ bn_v b < bn_v n) (ensures bn_v (bn_sub_mod_n n a b) == (bn_v a - bn_v b) % bn_v n) let bn_sub_mod_n_lemma #t #len n a b =
false
null
true
let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then (assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); ()) else (bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); ())
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Base.carry", "Prims.op_Equality", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Prims.unit", "Prims._assert", "Prims.eq2", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_Modulus", "Prims.op_Subtraction", "FStar.Math.Lemmas.small_mod", "Prims.bool", "FStar.Math.Lemmas.modulo_addition_lemma", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Addition", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "FStar.Mul.op_Star", "Prims.pow2", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.bn_add_lemma", "Hacl.Spec.Bignum.Base.lseq_mask_select_lemma", "Lib.Sequence.lseq", "Hacl.Spec.Bignum.Definitions.limb", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Lib.Sequence.index", "Hacl.Spec.Bignum.Base.mask_select", "Lib.Sequence.map2", "Prims.l_or", "Lib.IntTypes.range_t", "Lib.IntTypes.ones", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.uint", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.bn_add", "Hacl.Spec.Bignum.bn_sub_lemma", "Hacl.Spec.Bignum.bn_sub" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0
false
false
Hacl.Spec.Bignum.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_sub_mod_n_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> Lemma (requires bn_v a < bn_v n /\ bn_v b < bn_v n) (ensures bn_v (bn_sub_mod_n n a b) == (bn_v a - bn_v b) % bn_v n)
[]
Hacl.Spec.Bignum.bn_sub_mod_n_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> b: Hacl.Spec.Bignum.Definitions.lbignum t len -> FStar.Pervasives.Lemma (requires Hacl.Spec.Bignum.Definitions.bn_v a < Hacl.Spec.Bignum.Definitions.bn_v n /\ Hacl.Spec.Bignum.Definitions.bn_v b < Hacl.Spec.Bignum.Definitions.bn_v n) (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_sub_mod_n n a b) == (Hacl.Spec.Bignum.Definitions.bn_v a - Hacl.Spec.Bignum.Definitions.bn_v b) % Hacl.Spec.Bignum.Definitions.bn_v n)
{ "end_col": 10, "end_line": 114, "start_col": 38, "start_line": 86 }
FStar.Pervasives.Lemma
val bn_reduce_once_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> c:carry t -> a:lbignum t len -> Lemma (requires v c * pow2 (bits t * len) + bn_v a < 2 * bn_v n) (ensures bn_v (bn_reduce_once n c a) == (v c * pow2 (bits t * len) + bn_v a) % bn_v n)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end
val bn_reduce_once_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> c:carry t -> a:lbignum t len -> Lemma (requires v c * pow2 (bits t * len) + bn_v a < 2 * bn_v n) (ensures bn_v (bn_reduce_once n c a) == (v c * pow2 (bits t * len) + bn_v a) % bn_v n) let bn_reduce_once_lemma #t #len n c0 res0 =
false
null
true
let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then (assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n)) else (assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n))
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Base.carry", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Prims.nat", "Hacl.Spec.Bignum.Base.lseq_mask_select_lemma", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Prims.op_Subtraction", "Prims.pow2", "Prims.bool", "FStar.Math.Lemmas.modulo_addition_lemma", "Prims.op_Minus", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "Prims.b2t", "Lib.Sequence.lseq", "Hacl.Spec.Bignum.Definitions.limb", "Prims.l_Forall", "Prims.l_imp", "Lib.Sequence.index", "Hacl.Spec.Bignum.Base.mask_select", "Lib.Sequence.map2", "Prims.op_Addition", "FStar.Mul.op_Star", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Subtraction_Dot", "Hacl.Spec.Bignum.bn_sub_lemma", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.bn_sub", "Lib.IntTypes.bits" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res
false
false
Hacl.Spec.Bignum.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_reduce_once_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> c:carry t -> a:lbignum t len -> Lemma (requires v c * pow2 (bits t * len) + bn_v a < 2 * bn_v n) (ensures bn_v (bn_reduce_once n c a) == (v c * pow2 (bits t * len) + bn_v a) % bn_v n)
[]
Hacl.Spec.Bignum.bn_reduce_once_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> c: Hacl.Spec.Bignum.Base.carry t -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> FStar.Pervasives.Lemma (requires Lib.IntTypes.v c * Prims.pow2 (Lib.IntTypes.bits t * len) + Hacl.Spec.Bignum.Definitions.bn_v a < 2 * Hacl.Spec.Bignum.Definitions.bn_v n) (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_reduce_once n c a) == (Lib.IntTypes.v c * Prims.pow2 (Lib.IntTypes.bits t * len) + Hacl.Spec.Bignum.Definitions.bn_v a) % Hacl.Spec.Bignum.Definitions.bn_v n)
{ "end_col": 49, "end_line": 65, "start_col": 44, "start_line": 38 }
Prims.Tot
val bn_sub_mod_n: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> lbignum t len
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0
val bn_sub_mod_n: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> lbignum t len let bn_sub_mod_n #t #len n a b =
false
null
false
let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Base.carry", "Lib.Sequence.map2", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Base.mask_select", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.uint", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.bn_add", "Hacl.Spec.Bignum.bn_sub" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0
false
false
Hacl.Spec.Bignum.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_sub_mod_n: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> b:lbignum t len -> lbignum t len
[]
Hacl.Spec.Bignum.bn_sub_mod_n
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> b: Hacl.Spec.Bignum.Definitions.lbignum t len -> Hacl.Spec.Bignum.Definitions.lbignum t len
{ "end_col": 32, "end_line": 83, "start_col": 32, "start_line": 79 }
Prims.Tot
val bn_karatsuba_mul: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t aLen -> lbignum t (aLen + aLen)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b
val bn_karatsuba_mul: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t aLen -> lbignum t (aLen + aLen) let bn_karatsuba_mul #t #aLen a b =
false
null
false
Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b
false
false
Hacl.Spec.Bignum.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_karatsuba_mul: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t aLen -> lbignum t (aLen + aLen)
[]
Hacl.Spec.Bignum.bn_karatsuba_mul
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> Hacl.Spec.Bignum.Definitions.lbignum t (aLen + aLen)
{ "end_col": 49, "end_line": 130, "start_col": 2, "start_line": 130 }
FStar.Pervasives.Lemma
val bn_mul_lemma: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{aLen + bLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t bLen -> Lemma (bn_v (bn_mul a b) == bn_v a * bn_v b)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b
val bn_mul_lemma: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{aLen + bLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t bLen -> Lemma (bn_v (bn_mul a b) == bn_v a * bn_v b) let bn_mul_lemma #t #aLen #bLen a b =
false
null
true
Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Multiplication.bn_mul_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b
false
false
Hacl.Spec.Bignum.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_mul_lemma: #t:limb_t -> #aLen:size_nat -> #bLen:size_nat{aLen + bLen <= max_size_t} -> a:lbignum t aLen -> b:lbignum t bLen -> Lemma (bn_v (bn_mul a b) == bn_v a * bn_v b)
[]
Hacl.Spec.Bignum.bn_mul_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> b: Hacl.Spec.Bignum.Definitions.lbignum t bLen -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_mul a b) == Hacl.Spec.Bignum.Definitions.bn_v a * Hacl.Spec.Bignum.Definitions.bn_v b)
{ "end_col": 50, "end_line": 127, "start_col": 2, "start_line": 127 }
FStar.Pervasives.Lemma
val bn_is_odd_lemma: #t:limb_t -> #len:size_pos -> a:lbignum t len -> Lemma (v (bn_is_odd a) == (bn_v a % 2))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b
val bn_is_odd_lemma: #t:limb_t -> #len:size_pos -> a:lbignum t len -> Lemma (v (bn_is_odd a) == (bn_v a % 2)) let bn_is_odd_lemma #t #len b =
false
null
true
Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b
false
false
Hacl.Spec.Bignum.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_lemma: #t:limb_t -> #len:size_pos -> a:lbignum t len -> Lemma (v (bn_is_odd a) == (bn_v a % 2))
[]
Hacl.Spec.Bignum.bn_is_odd_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t len -> FStar.Pervasives.Lemma (ensures Lib.IntTypes.v (Hacl.Spec.Bignum.bn_is_odd a) == Hacl.Spec.Bignum.Definitions.bn_v a % 2)
{ "end_col": 47, "end_line": 216, "start_col": 2, "start_line": 216 }
FStar.Pervasives.Lemma
val bn_sqr_lemma: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> Lemma (bn_sqr a == bn_mul a a /\ bn_v (bn_sqr a) == bn_v a * bn_v a)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a
val bn_sqr_lemma: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> Lemma (bn_sqr a == bn_mul a a /\ bn_v (bn_sqr a) == bn_v a * bn_v a) let bn_sqr_lemma #t #aLen a =
false
null
true
Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Squaring.bn_sqr_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a
false
false
Hacl.Spec.Bignum.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_sqr_lemma: #t:limb_t -> #aLen:size_nat{aLen + aLen <= max_size_t} -> a:lbignum t aLen -> Lemma (bn_sqr a == bn_mul a a /\ bn_v (bn_sqr a) == bn_v a * bn_v a)
[]
Hacl.Spec.Bignum.bn_sqr_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.Spec.Bignum.Definitions.lbignum t aLen -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.bn_sqr a == Hacl.Spec.Bignum.bn_mul a a /\ Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_sqr a) == Hacl.Spec.Bignum.Definitions.bn_v a * Hacl.Spec.Bignum.Definitions.bn_v a)
{ "end_col": 42, "end_line": 139, "start_col": 2, "start_line": 139 }
FStar.Pervasives.Lemma
val bn_get_ith_bit_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> Lemma (v (bn_get_ith_bit b i) == (bn_v b / pow2 i % 2))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind
val bn_get_ith_bit_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> Lemma (v (bn_get_ith_bit b i) == (bn_v b / pow2 i % 2)) let bn_get_ith_bit_lemma #t #len b ind =
false
null
true
Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind
false
false
Hacl.Spec.Bignum.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_get_ith_bit_lemma: #t:limb_t -> #len:size_nat -> b:lbignum t len -> i:size_nat{i / bits t < len} -> Lemma (v (bn_get_ith_bit b i) == (bn_v b / pow2 i % 2))
[]
Hacl.Spec.Bignum.bn_get_ith_bit_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum t len -> i: Lib.IntTypes.size_nat{i / Lib.IntTypes.bits t < len} -> FStar.Pervasives.Lemma (ensures Lib.IntTypes.v (Hacl.Spec.Bignum.bn_get_ith_bit b i) == Hacl.Spec.Bignum.Definitions.bn_v b / Prims.pow2 i % 2)
{ "end_col": 49, "end_line": 188, "start_col": 2, "start_line": 188 }
FStar.Pervasives.Lemma
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t -> Lemma (bn_v (bn_from_uint len x) == uint_v x)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_from_uint_lemma #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x
val bn_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t -> Lemma (bn_v (bn_from_uint len x) == uint_v x) let bn_from_uint_lemma #t len x =
false
null
true
Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Convert.bn_from_uint_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *) let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x
false
false
Hacl.Spec.Bignum.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_from_uint_lemma: #t:limb_t -> len:size_pos -> x:limb t -> Lemma (bn_v (bn_from_uint len x) == uint_v x)
[]
Hacl.Spec.Bignum.bn_from_uint_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos -> x: Hacl.Spec.Bignum.Definitions.limb t -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_from_uint len x) == Lib.IntTypes.uint_v x)
{ "end_col": 51, "end_line": 254, "start_col": 2, "start_line": 254 }
FStar.Pervasives.Lemma
val bn_to_bytes_be_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} -> Lemma (bn_to_bytes_be #t len b == BSeq.nat_to_intseq_be #U8 len (bn_v b))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_to_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma len b
val bn_to_bytes_be_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} -> Lemma (bn_to_bytes_be #t len b == BSeq.nat_to_intseq_be #U8 len (bn_v b)) let bn_to_bytes_be_lemma #t len b =
false
null
true
Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma len b
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.pow2", "Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma", "Prims.unit" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a (* get and set i-th bit of a bignum *) let bn_get_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit input ind let bn_get_ith_bit_lemma #t #len b ind = Hacl.Spec.Bignum.Lib.bn_get_ith_bit_lemma b ind let bn_get_bits #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits #t #nLen n i l let bn_get_bits_lemma #t #nLen n i l = Hacl.Spec.Bignum.Lib.bn_get_bits_lemma #t #nLen n i l let bn_set_ith_bit #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit input ind let bn_set_ith_bit_lemma #t #len input ind = Hacl.Spec.Bignum.Lib.bn_set_ith_bit_lemma input ind (* conditional swap *) let cswap2 #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2 bit b1 b2 let cswap2_lemma #t #len bit b1 b2 = Hacl.Spec.Bignum.Lib.cswap2_lemma bit b1 b2 (* Bignum comparison and test functions *) let bn_is_odd #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd b let bn_is_odd_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_odd_lemma b let bn_eq_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask a b let bn_eq_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_eq_mask_lemma a b let bn_is_zero_mask #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask b let bn_is_zero_mask_lemma #t #len b = Hacl.Spec.Bignum.Comparison.bn_is_zero_mask_lemma b let bn_lt_mask #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask a b let bn_lt_mask_lemma #t #len a b = Hacl.Spec.Bignum.Comparison.bn_lt_mask_lemma a b let bn_lt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask b x let bn_lt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_lt_pow2_mask_lemma b x let bn_gt_pow2_mask #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask b x let bn_gt_pow2_mask_lemma #t #len b x = Hacl.Spec.Bignum.Comparison.bn_gt_pow2_mask_lemma b x (* Conversion functions *) let bn_from_uint #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint len x let bn_from_uint_lemma #t len x = Hacl.Spec.Bignum.Convert.bn_from_uint_lemma len x let bn_from_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be len b let bn_from_bytes_be_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #t len b let bn_from_bytes_le #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le #t len b let bn_from_bytes_le_lemma #t len b = Hacl.Spec.Bignum.Convert.bn_from_bytes_le_lemma #t len b let bn_to_bytes_be #t len b = Hacl.Spec.Bignum.Convert.bn_to_bytes_be len b
false
false
Hacl.Spec.Bignum.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_to_bytes_be_lemma: #t:limb_t -> len:size_pos{numbytes t * (blocks len (numbytes t)) <= max_size_t} -> b:lbignum t (blocks len (numbytes t)){bn_v b < pow2 (8 * len)} -> Lemma (bn_to_bytes_be #t len b == BSeq.nat_to_intseq_be #U8 len (bn_v b))
[]
Hacl.Spec.Bignum.bn_to_bytes_be_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_pos { Lib.IntTypes.numbytes t * Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t) <= Lib.IntTypes.max_size_t } -> b: Hacl.Spec.Bignum.Definitions.lbignum t (Hacl.Spec.Bignum.Definitions.blocks len (Lib.IntTypes.numbytes t)) {Hacl.Spec.Bignum.Definitions.bn_v b < Prims.pow2 (8 * len)} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Bignum.bn_to_bytes_be len b == Lib.ByteSequence.nat_to_intseq_be len (Hacl.Spec.Bignum.Definitions.bn_v b))
{ "end_col": 53, "end_line": 272, "start_col": 2, "start_line": 272 }
FStar.Pervasives.Lemma
val bn_sub_mask_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> Lemma (requires bn_v a <= bn_v n) (ensures bn_v (bn_sub_mask n a) == (if bn_v a = bn_v n then 0 else bn_v a))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_sub_mask_lemma #t #len n a = let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a
val bn_sub_mask_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> Lemma (requires bn_v a <= bn_v n) (ensures bn_v (bn_sub_mask n a) == (if bn_v a = bn_v n then 0 else bn_v a)) let bn_sub_mask_lemma #t #len n a =
false
null
true
let mask = Lib.ByteSequence.seq_eq_mask n a len in assert (n == a ==> v mask == v (ones t SEC)); assert (n =!= a ==> v mask == v (zeros t SEC)); let mod_mask = map (logand mask) n in bn_mask_lemma n mask; assert (n == a ==> bn_v mod_mask == bn_v n); assert (n =!= a ==> bn_v mod_mask == 0); let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in Hacl.Spec.Bignum.Addition.bn_sub_lemma a mod_mask; assert (bn_v res - v c * pow2 (bits t * len) == bn_v a - bn_v mod_mask); bn_eval_bound res len; assert (bn_v res == bn_v a - bn_v mod_mask); Classical.move_requires_2 (bn_eval_inj len) n a
{ "checked_file": "Hacl.Spec.Bignum.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.ByteSequence.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Spec.Bignum.Karatsuba.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.Comparison.fst.checked", "Hacl.Spec.Bignum.Addition.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Hacl.Spec.Bignum.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Base.carry", "FStar.Classical.move_requires_2", "Prims.eq2", "Prims.nat", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.Sequence.equal", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Definitions.bn_eval_inj", "Prims.unit", "Prims._assert", "Prims.int", "Prims.op_Subtraction", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "FStar.Mul.op_Star", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Prims.pow2", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Addition.bn_sub_lemma", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Addition.bn_sub", "Prims.l_imp", "Prims.l_not", "Hacl.Spec.Bignum.Definitions.bn_mask_lemma", "Lib.Sequence.lseq", "Prims.l_Forall", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.index", "Lib.IntTypes.logand", "Lib.Sequence.map", "Lib.IntTypes.range_t", "Lib.IntTypes.zeros", "Lib.IntTypes.ones", "Lib.IntTypes.int_t", "Prims.l_and", "Prims.l_or", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.sub", "Lib.IntTypes.range", "Lib.ByteSequence.seq_eq_mask" ]
[]
module Hacl.Spec.Bignum module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_add1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1 a b1 let bn_add1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_add1_lemma a b1 let bn_sub1 #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1 a b1 let bn_sub1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Addition.bn_sub1_lemma a b1 let bn_add #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add a b let bn_add_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_add_lemma a b let bn_sub #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub a b let bn_sub_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Addition.bn_sub_lemma a b let bn_reduce_once #t #len n c0 a = let c1, res = bn_sub a n in let c = c0 -. c1 in map2 (mask_select c) a res let bn_reduce_once_lemma #t #len n c0 res0 = let pbits = bits t in let tmp = bn_v res0 + v c0 * pow2 (pbits * len) in let c1, res1 = bn_sub res0 n in bn_sub_lemma res0 n; assert (bn_v res1 - v c1 * pow2 (pbits * len) == bn_v res0 - bn_v n); let c = c0 -. c1 in assert (bn_v res1 + (v c0 - v c1) * pow2 (pbits * len) == tmp - bn_v n); let res = map2 (mask_select c) res0 res1 in if tmp < bn_v n then begin assert (v c0 == 0); assert (v c1 == 1); assert (v c == pow2 pbits - 1); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res0); Math.Lemmas.small_mod tmp (bn_v n); assert (bn_v res == tmp % bn_v n) end else begin assert (tmp - bn_v n < bn_v n); bn_eval_bound res1 len; bn_eval_bound n len; assert (v c == 0); lseq_mask_select_lemma res0 res1 c; assert (bn_v res == bn_v res1); Math.Lemmas.modulo_addition_lemma tmp (bn_v n) (- 1); assert (bn_v res % bn_v n == tmp % bn_v n); Math.Lemmas.small_mod (bn_v res) (bn_v n) end let bn_add_mod_n #t #len n a b = let c0, res0 = bn_add a b in bn_reduce_once n c0 res0 let bn_add_mod_n_lemma #t #len n a b = let c0, res0 = bn_add a b in bn_add_lemma a b; bn_reduce_once_lemma n c0 res0 let bn_sub_mod_n #t #len n a b = let c0, res0 = bn_sub a b in let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in map2 (mask_select c) res1 res0 let bn_sub_mod_n_lemma #t #len n a b = let c0, res0 = bn_sub a b in bn_sub_lemma a b; assert (bn_v res0 - v c0 * pow2 (bits t * len) == bn_v a - bn_v b); let c1, res1 = bn_add res0 n in let c = uint #t 0 -. c0 in assert (v c == 0 \/ v c == v (ones t SEC)); let res = map2 (mask_select c) res1 res0 in lseq_mask_select_lemma res1 res0 c; if v c0 = 0 then begin assert (bn_v res0 == bn_v a - bn_v b); Math.Lemmas.small_mod (bn_v res0) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end else begin bn_add_lemma res0 n; assert (bn_v res1 + v c1 * pow2 (bits t * len) == bn_v res0 + bn_v n); bn_eval_bound res0 len; bn_eval_bound res1 len; bn_eval_bound n len; assert (v c0 - v c1 = 0); assert (bn_v res1 == bn_v a - bn_v b + bn_v n); assert (bn_v res1 < bn_v n); Math.Lemmas.modulo_addition_lemma (bn_v a - bn_v b) (bn_v n) 1; Math.Lemmas.small_mod (bn_v res1) (bn_v n); assert (bn_v res == (bn_v a - bn_v b) % bn_v n); () end let bn_mul1 #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1 a b1 let bn_mul1_lemma #t #aLen a b1 = Hacl.Spec.Bignum.Multiplication.bn_mul1_lemma a b1 let bn_mul #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul a b let bn_mul_lemma #t #aLen #bLen a b = Hacl.Spec.Bignum.Multiplication.bn_mul_lemma a b let bn_karatsuba_mul #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul a b let bn_karatsuba_mul_lemma #t #aLen a b = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_lemma a b let bn_sqr #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr a let bn_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Squaring.bn_sqr_lemma a let bn_karatsuba_sqr #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr a let bn_karatsuba_sqr_lemma #t #aLen a = Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_lemma a let bn_mul1_lshift_add #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add a b j acc let bn_mul1_lshift_add_lemma #t #aLen #resLen a b j acc = Hacl.Spec.Bignum.Multiplication.bn_mul1_lshift_add_lemma a b j acc let bn_rshift #t #len b i = Hacl.Spec.Bignum.Lib.bn_div_pow2 b i let bn_rshift_lemma #t #len c i = Hacl.Spec.Bignum.Lib.bn_div_pow2_lemma c i let bn_sub_mask #t #len n a = let mask = BSeq.seq_eq_mask n a len in let mod_mask = map (logand mask) n in let c, res = Hacl.Spec.Bignum.Addition.bn_sub a mod_mask in res
false
false
Hacl.Spec.Bignum.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_sub_mask_lemma: #t:limb_t -> #len:size_nat -> n:lbignum t len -> a:lbignum t len -> Lemma (requires bn_v a <= bn_v n) (ensures bn_v (bn_sub_mask n a) == (if bn_v a = bn_v n then 0 else bn_v a))
[]
Hacl.Spec.Bignum.bn_sub_mask_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> FStar.Pervasives.Lemma (requires Hacl.Spec.Bignum.Definitions.bn_v a <= Hacl.Spec.Bignum.Definitions.bn_v n) (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.bn_sub_mask n a) == (match Hacl.Spec.Bignum.Definitions.bn_v a = Hacl.Spec.Bignum.Definitions.bn_v n with | true -> 0 | _ -> Hacl.Spec.Bignum.Definitions.bn_v a))
{ "end_col": 49, "end_line": 180, "start_col": 35, "start_line": 165 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Transformers.PeepHole", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers.InstructionReorder", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Print_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers", "short_module": null }, { "abbrev": 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 prefetch_elim_ph = { ph = (function | [Instr i oprs (AnnotatePrefetchnta ())] -> Some [] | _ -> None); input_hint = 1; }
let prefetch_elim_ph =
false
null
false
{ ph = (function | [Instr i oprs (AnnotatePrefetchnta ())] -> Some [] | _ -> None); input_hint = 1 }
{ "checked_file": "Vale.Transformers.PrefetchElim.fst.checked", "dependencies": [ "Vale.X64.Print_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Transformers.PeepHole.fsti.checked", "Vale.Transformers.InstructionReorder.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Transformers.PrefetchElim.fst" }
[ "total" ]
[ "Vale.Transformers.PeepHole.Mkpre_peephole", "Prims.list", "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Instruction_s.instr_t_record", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args", "FStar.Pervasives.Native.Some", "Prims.Nil", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.Transformers.PrefetchElim open Vale.X64.Bytes_Code_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Print_s open Vale.Transformers.InstructionReorder open Vale.X64.InsLemmas open Vale.Transformers.PeepHole
false
true
Vale.Transformers.PrefetchElim.fst
{ "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 prefetch_elim_ph : Vale.Transformers.PeepHole.pre_peephole
[]
Vale.Transformers.PrefetchElim.prefetch_elim_ph
{ "file_name": "vale/code/lib/transformers/Vale.Transformers.PrefetchElim.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Transformers.PeepHole.pre_peephole
{ "end_col": 17, "end_line": 19, "start_col": 2, "start_line": 15 }
FStar.Pervasives.Lemma
val prefetch_elim_correct (is: list ins) (s: machine_state) : Lemma (peephole_correct prefetch_elim_ph is s) [SMTPat (peephole_correct prefetch_elim_ph is s)]
[ { "abbrev": false, "full_module": "Vale.Transformers.PeepHole", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers.InstructionReorder", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Print_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers", "short_module": null }, { "abbrev": 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 prefetch_elim_correct (is:list ins) (s:machine_state) : Lemma (peephole_correct prefetch_elim_ph is s) [SMTPat (peephole_correct prefetch_elim_ph is s)] = match is with | [Instr i oprs (AnnotatePrefetchnta ())] -> () | _ -> ()
val prefetch_elim_correct (is: list ins) (s: machine_state) : Lemma (peephole_correct prefetch_elim_ph is s) [SMTPat (peephole_correct prefetch_elim_ph is s)] let prefetch_elim_correct (is: list ins) (s: machine_state) : Lemma (peephole_correct prefetch_elim_ph is s) [SMTPat (peephole_correct prefetch_elim_ph is s)] =
false
null
true
match is with | [Instr i oprs (AnnotatePrefetchnta ())] -> () | _ -> ()
{ "checked_file": "Vale.Transformers.PrefetchElim.fst.checked", "dependencies": [ "Vale.X64.Print_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Transformers.PeepHole.fsti.checked", "Vale.Transformers.InstructionReorder.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Transformers.PrefetchElim.fst" }
[ "lemma" ]
[ "Prims.list", "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Instruction_s.instr_t_record", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args", "Prims.unit", "Prims.l_True", "Prims.squash", "Vale.Transformers.PeepHole.peephole_correct", "Vale.Transformers.PrefetchElim.prefetch_elim_ph", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Vale.Transformers.PrefetchElim open Vale.X64.Bytes_Code_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Print_s open Vale.Transformers.InstructionReorder open Vale.X64.InsLemmas open Vale.Transformers.PeepHole let prefetch_elim_ph = { ph = (function | [Instr i oprs (AnnotatePrefetchnta ())] -> Some [] | _ -> None); input_hint = 1; } #push-options "--fuel 2 --ifuel 3" let prefetch_elim_correct (is:list ins) (s:machine_state) : Lemma (peephole_correct prefetch_elim_ph is s)
false
false
Vale.Transformers.PrefetchElim.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 3, "max_fuel": 2, "max_ifuel": 3, "no_plugins": false, "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 prefetch_elim_correct (is: list ins) (s: machine_state) : Lemma (peephole_correct prefetch_elim_ph is s) [SMTPat (peephole_correct prefetch_elim_ph is s)]
[]
Vale.Transformers.PrefetchElim.prefetch_elim_correct
{ "file_name": "vale/code/lib/transformers/Vale.Transformers.PrefetchElim.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
is: Prims.list Vale.X64.Machine_Semantics_s.ins -> s: Vale.X64.Machine_Semantics_s.machine_state -> FStar.Pervasives.Lemma (ensures Vale.Transformers.PeepHole.peephole_correct Vale.Transformers.PrefetchElim.prefetch_elim_ph is s) [ SMTPat (Vale.Transformers.PeepHole.peephole_correct Vale.Transformers.PrefetchElim.prefetch_elim_ph is s) ]
{ "end_col": 11, "end_line": 28, "start_col": 2, "start_line": 26 }
Prims.Tot
val parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f)
val parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) =
false
null
false
parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f)
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.Spec.Enum.enum", "LowParse.Spec.Enum.maybe_enum_key_of_repr'_t", "LowParse.SLow.Enum.parse32_enum_key_gen", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.SLow.Enum.parse32_maybe_enum_key" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e))
[]
LowParse.SLow.Enum.parse32_enum_key
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p32: LowParse.SLow.Base.parser32 p -> e: LowParse.Spec.Enum.enum key repr -> f: LowParse.Spec.Enum.maybe_enum_key_of_repr'_t e -> LowParse.SLow.Base.parser32 (LowParse.Spec.Enum.parse_enum_key p e)
{ "end_col": 93, "end_line": 78, "start_col": 2, "start_line": 78 }
Prims.Tot
val parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f
val parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) =
false
null
false
parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.Spec.Enum.enum", "LowParse.Spec.Enum.maybe_enum_key_of_repr'_t", "LowParse.SLow.Enum.parse32_maybe_enum_key_gen", "LowParse.Spec.Enum.maybe_enum_key", "LowParse.Spec.Enum.parse_maybe_enum_key" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e))
[]
LowParse.SLow.Enum.parse32_maybe_enum_key
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p32: LowParse.SLow.Base.parser32 p -> e: LowParse.Spec.Enum.enum key repr -> f: LowParse.Spec.Enum.maybe_enum_key_of_repr'_t e -> LowParse.SLow.Base.parser32 (LowParse.Spec.Enum.parse_maybe_enum_key p e)
{ "end_col": 76, "end_line": 36, "start_col": 2, "start_line": 36 }
Prims.Tot
val serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) = serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f
val serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) =
false
null
false
serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.Spec.Enum.enum", "LowParse.Spec.Enum.enum_repr_of_key'_t", "LowParse.SLow.Enum.serialize32_enum_key_gen", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.Spec.Enum.serialize_enum_key" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } )) inline_for_extraction let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e))
[]
LowParse.SLow.Enum.serialize32_enum_key
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.serializer32 s -> e: LowParse.Spec.Enum.enum key repr -> f: LowParse.Spec.Enum.enum_repr_of_key'_t e -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Enum.serialize_enum_key p s e)
{ "end_col": 79, "end_line": 113, "start_col": 2, "start_line": 113 }
Prims.Tot
val size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e)) = size32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f
val size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e)) let size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e)) =
false
null
false
size32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "LowParse.Spec.Enum.enum", "LowParse.Spec.Enum.enum_repr_of_key'_t", "LowParse.SLow.Enum.size32_enum_key_gen", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.Spec.Enum.serialize_enum_key" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } )) inline_for_extraction let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) = serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: UInt32.t { size32_postcond (serialize_enum_key p s e) input r } )) inline_for_extraction let size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e))
[]
LowParse.SLow.Enum.size32_enum_key
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.size32 s -> e: LowParse.Spec.Enum.enum key repr -> f: LowParse.Spec.Enum.enum_repr_of_key'_t e -> LowParse.SLow.Base.size32 (LowParse.Spec.Enum.serialize_enum_key p s e)
{ "end_col": 74, "end_line": 148, "start_col": 2, "start_line": 148 }
Prims.Tot
val serialize32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_maybe_enum_key p s e))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = serialize32_maybe_enum_key_gen s32 e _ _ _ (serialize_maybe_enum_key p s e) () () () () f
val serialize32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_maybe_enum_key p s e)) let serialize32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_maybe_enum_key p s e)) =
false
null
false
serialize32_maybe_enum_key_gen s32 e _ _ _ (serialize_maybe_enum_key p s e) () () () () f
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.Spec.Enum.enum", "LowParse.Spec.Enum.enum_repr_of_key'_t", "LowParse.SLow.Enum.serialize32_maybe_enum_key_gen", "LowParse.Spec.Enum.maybe_enum_key", "LowParse.Spec.Enum.parse_maybe_enum_key", "LowParse.Spec.Enum.serialize_maybe_enum_key" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } )) inline_for_extraction let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) = serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: UInt32.t { size32_postcond (serialize_enum_key p s e) input r } )) inline_for_extraction let size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e)) = size32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let serialize32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = fun (input: maybe_enum_key e) -> (( [@inline_let] let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@inline_let] let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r ) <: (r: bytes32 { serializer32_correct (serialize_maybe_enum_key p s e) input r } )) inline_for_extraction let serialize32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k == k' } ) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (u3: unit { s' == serialize_maybe_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = serialize32_maybe_enum_key_gen' s32 e (serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key _ s e) () () () () f) inline_for_extraction let serialize32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_maybe_enum_key p s e))
[]
LowParse.SLow.Enum.serialize32_maybe_enum_key
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.serializer32 s -> e: LowParse.Spec.Enum.enum key repr -> f: LowParse.Spec.Enum.enum_repr_of_key'_t e -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Enum.serialize_maybe_enum_key p s e)
{ "end_col": 91, "end_line": 202, "start_col": 2, "start_line": 202 }
Prims.Tot
val size32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_maybe_enum_key p s e))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_maybe_enum_key p s e)) = size32_maybe_enum_key_gen s32 e _ _ _ (serialize_maybe_enum_key p s e) () () () () f
val size32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_maybe_enum_key p s e)) let size32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_maybe_enum_key p s e)) =
false
null
false
size32_maybe_enum_key_gen s32 e _ _ _ (serialize_maybe_enum_key p s e) () () () () f
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "LowParse.Spec.Enum.enum", "LowParse.Spec.Enum.enum_repr_of_key'_t", "LowParse.SLow.Enum.size32_maybe_enum_key_gen", "LowParse.Spec.Enum.maybe_enum_key", "LowParse.Spec.Enum.parse_maybe_enum_key", "LowParse.Spec.Enum.serialize_maybe_enum_key" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } )) inline_for_extraction let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) = serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: UInt32.t { size32_postcond (serialize_enum_key p s e) input r } )) inline_for_extraction let size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e)) = size32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let serialize32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = fun (input: maybe_enum_key e) -> (( [@inline_let] let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@inline_let] let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r ) <: (r: bytes32 { serializer32_correct (serialize_maybe_enum_key p s e) input r } )) inline_for_extraction let serialize32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k == k' } ) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (u3: unit { s' == serialize_maybe_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = serialize32_maybe_enum_key_gen' s32 e (serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key _ s e) () () () () f) inline_for_extraction let serialize32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = serialize32_maybe_enum_key_gen s32 e _ _ _ (serialize_maybe_enum_key p s e) () () () () f inline_for_extraction let size32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: size32 (serialize_enum_key p s e)) : Tot (size32 (serialize_maybe_enum_key p s e)) = fun (input: maybe_enum_key e) -> (( [@inline_let] let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@inline_let] let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r ) <: (r: U32.t { size32_postcond (serialize_maybe_enum_key p s e) input r } )) inline_for_extraction let size32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k == k' } ) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (u3: unit { s' == serialize_maybe_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = size32_maybe_enum_key_gen' s32 e (size32_enum_key_gen s32 e _ _ _ (serialize_enum_key _ s e) () () () () f) inline_for_extraction let size32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_maybe_enum_key p s e))
[]
LowParse.SLow.Enum.size32_maybe_enum_key
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.size32 s -> e: LowParse.Spec.Enum.enum key repr -> f: LowParse.Spec.Enum.enum_repr_of_key'_t e -> LowParse.SLow.Base.size32 (LowParse.Spec.Enum.serialize_maybe_enum_key p s e)
{ "end_col": 87, "end_line": 256, "start_col": 2, "start_line": 256 }
Prims.Tot
val serialize32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = fun (input: maybe_enum_key e) -> (( [@inline_let] let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@inline_let] let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r ) <: (r: bytes32 { serializer32_correct (serialize_maybe_enum_key p s e) input r } ))
val serialize32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e)) let serialize32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e)) =
false
null
false
fun (input: maybe_enum_key e) -> (([@@ inline_let ]let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@@ inline_let ]let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r) <: (r: bytes32{serializer32_correct (serialize_maybe_enum_key p s e) input r}))
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.Spec.Enum.enum", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.Spec.Enum.serialize_enum_key", "LowParse.Spec.Enum.maybe_enum_key", "Prims.unit", "LowParse.Spec.Enum.serialize_enum_key_eq", "LowParse.Spec.Enum.unknown_enum_repr", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Enum.parse_maybe_enum_key", "LowParse.Spec.Enum.serialize_maybe_enum_key", "LowParse.Spec.Enum.serialize_maybe_enum_key_eq" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } )) inline_for_extraction let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) = serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: UInt32.t { size32_postcond (serialize_enum_key p s e) input r } )) inline_for_extraction let size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e)) = size32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let serialize32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e))
false
false
LowParse.SLow.Enum.fst
{ "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_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e))
[]
LowParse.SLow.Enum.serialize32_maybe_enum_key_gen'
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.serializer32 s -> e: LowParse.Spec.Enum.enum key repr -> f: LowParse.SLow.Base.serializer32 (LowParse.Spec.Enum.serialize_enum_key p s e) -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Enum.serialize_maybe_enum_key p s e)
{ "end_col": 88, "end_line": 169, "start_col": 2, "start_line": 160 }
Prims.Tot
val size32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: size32 (serialize_enum_key p s e)) : Tot (size32 (serialize_maybe_enum_key p s e))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: size32 (serialize_enum_key p s e)) : Tot (size32 (serialize_maybe_enum_key p s e)) = fun (input: maybe_enum_key e) -> (( [@inline_let] let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@inline_let] let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r ) <: (r: U32.t { size32_postcond (serialize_maybe_enum_key p s e) input r } ))
val size32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: size32 (serialize_enum_key p s e)) : Tot (size32 (serialize_maybe_enum_key p s e)) let size32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: size32 (serialize_enum_key p s e)) : Tot (size32 (serialize_maybe_enum_key p s e)) =
false
null
false
fun (input: maybe_enum_key e) -> (([@@ inline_let ]let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@@ inline_let ]let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r) <: (r: U32.t{size32_postcond (serialize_maybe_enum_key p s e) input r}))
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "LowParse.Spec.Enum.enum", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.Spec.Enum.serialize_enum_key", "LowParse.Spec.Enum.maybe_enum_key", "Prims.unit", "LowParse.Spec.Enum.serialize_enum_key_eq", "LowParse.Spec.Enum.unknown_enum_repr", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Enum.parse_maybe_enum_key", "LowParse.Spec.Enum.serialize_maybe_enum_key", "LowParse.Spec.Enum.serialize_maybe_enum_key_eq" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } )) inline_for_extraction let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) = serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: UInt32.t { size32_postcond (serialize_enum_key p s e) input r } )) inline_for_extraction let size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e)) = size32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let serialize32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = fun (input: maybe_enum_key e) -> (( [@inline_let] let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@inline_let] let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r ) <: (r: bytes32 { serializer32_correct (serialize_maybe_enum_key p s e) input r } )) inline_for_extraction let serialize32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k == k' } ) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (u3: unit { s' == serialize_maybe_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = serialize32_maybe_enum_key_gen' s32 e (serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key _ s e) () () () () f) inline_for_extraction let serialize32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = serialize32_maybe_enum_key_gen s32 e _ _ _ (serialize_maybe_enum_key p s e) () () () () f inline_for_extraction let size32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: size32 (serialize_enum_key p s e))
false
false
LowParse.SLow.Enum.fst
{ "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_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: size32 (serialize_enum_key p s e)) : Tot (size32 (serialize_maybe_enum_key p s e))
[]
LowParse.SLow.Enum.size32_maybe_enum_key_gen'
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.size32 s -> e: LowParse.Spec.Enum.enum key repr -> f: LowParse.SLow.Base.size32 (LowParse.Spec.Enum.serialize_enum_key p s e) -> LowParse.SLow.Base.size32 (LowParse.Spec.Enum.serialize_maybe_enum_key p s e)
{ "end_col": 81, "end_line": 223, "start_col": 2, "start_line": 214 }
Prims.Tot
val parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (u1: unit{k' == k}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p')
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 ()
val parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (u1: unit{k' == k}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (u1: unit{k' == k}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') =
false
null
false
parse32_synth p (maybe_enum_key_of_repr e) f p32 ()
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.Spec.Enum.enum", "Prims.unit", "Prims.eq2", "LowParse.Spec.Enum.maybe_enum_key", "LowParse.Spec.Enum.parse_maybe_enum_key", "LowParse.Spec.Enum.maybe_enum_key_of_repr'_t", "LowParse.SLow.Combinators.parse32_synth", "LowParse.Spec.Enum.maybe_enum_key_of_repr" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (u1: unit{k' == k}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p')
[]
LowParse.SLow.Enum.parse32_maybe_enum_key_gen
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p32: LowParse.SLow.Base.parser32 p -> e: LowParse.Spec.Enum.enum key repr -> k': LowParse.Spec.Base.parser_kind -> t': Type0 -> p': LowParse.Spec.Base.parser k' t' -> u1: Prims.unit{k' == k} -> u15: Prims.unit{t' == LowParse.Spec.Enum.maybe_enum_key e} -> u2: Prims.unit{p' == LowParse.Spec.Enum.parse_maybe_enum_key p e} -> f: LowParse.Spec.Enum.maybe_enum_key_of_repr'_t e -> LowParse.SLow.Base.parser32 p'
{ "end_col": 53, "end_line": 25, "start_col": 2, "start_line": 25 }
Prims.Tot
val serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (u3: unit{s' == serialize_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (serializer32 s')
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } ))
val serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (u3: unit{s' == serialize_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (u3: unit{s' == serialize_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') =
false
null
false
fun (input: enum_key e) -> ([@@ inline_let ]let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32{serializer32_correct (serialize_enum_key p s e) input r}))
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.Spec.Enum.enum", "Prims.unit", "Prims.eq2", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.Spec.Enum.serialize_enum_key", "LowParse.Spec.Enum.enum_repr_of_key'_t", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Enum.serialize_enum_key_eq" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (u3: unit{s' == serialize_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (serializer32 s')
[]
LowParse.SLow.Enum.serialize32_enum_key_gen
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.serializer32 s -> e: LowParse.Spec.Enum.enum key repr -> k': LowParse.Spec.Base.parser_kind -> t': Type0 -> p': LowParse.Spec.Base.parser k' t' -> s': LowParse.Spec.Base.serializer p' -> u1: Prims.unit{k' == LowParse.Spec.Combinators.parse_filter_kind k} -> u15: Prims.unit{t' == LowParse.Spec.Enum.enum_key e} -> u2: Prims.unit{p' == LowParse.Spec.Enum.parse_enum_key p e} -> u3: Prims.unit{s' == LowParse.Spec.Enum.serialize_enum_key p s e} -> f: LowParse.Spec.Enum.enum_repr_of_key'_t e -> LowParse.SLow.Base.serializer32 s'
{ "end_col": 97, "end_line": 101, "start_col": 2, "start_line": 98 }
Prims.Tot
val serialize32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k == k'}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (u3: unit{s' == serialize_maybe_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (serializer32 s')
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k == k' } ) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (u3: unit { s' == serialize_maybe_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = serialize32_maybe_enum_key_gen' s32 e (serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key _ s e) () () () () f)
val serialize32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k == k'}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (u3: unit{s' == serialize_maybe_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') let serialize32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k == k'}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (u3: unit{s' == serialize_maybe_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') =
false
null
false
serialize32_maybe_enum_key_gen' s32 e (serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key _ s e) () () () () f)
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.Spec.Enum.enum", "Prims.unit", "Prims.eq2", "LowParse.Spec.Enum.maybe_enum_key", "LowParse.Spec.Enum.parse_maybe_enum_key", "LowParse.Spec.Enum.serialize_maybe_enum_key", "LowParse.Spec.Enum.enum_repr_of_key'_t", "LowParse.SLow.Enum.serialize32_maybe_enum_key_gen'", "LowParse.SLow.Enum.serialize32_enum_key_gen", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.Spec.Enum.serialize_enum_key" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } )) inline_for_extraction let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) = serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: UInt32.t { size32_postcond (serialize_enum_key p s e) input r } )) inline_for_extraction let size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e)) = size32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let serialize32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = fun (input: maybe_enum_key e) -> (( [@inline_let] let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@inline_let] let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r ) <: (r: bytes32 { serializer32_correct (serialize_maybe_enum_key p s e) input r } )) inline_for_extraction let serialize32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k == k' } ) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (u3: unit { s' == serialize_maybe_enum_key p s e } ) (f: enum_repr_of_key'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k == k'}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (u3: unit{s' == serialize_maybe_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (serializer32 s')
[]
LowParse.SLow.Enum.serialize32_maybe_enum_key_gen
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.serializer32 s -> e: LowParse.Spec.Enum.enum key repr -> k': LowParse.Spec.Base.parser_kind -> t': Type0 -> p': LowParse.Spec.Base.parser k' t' -> s': LowParse.Spec.Base.serializer p' -> u1: Prims.unit{k == k'} -> u15: Prims.unit{t' == LowParse.Spec.Enum.maybe_enum_key e} -> u2: Prims.unit{p' == LowParse.Spec.Enum.parse_maybe_enum_key p e} -> u3: Prims.unit{s' == LowParse.Spec.Enum.serialize_maybe_enum_key p s e} -> f: LowParse.Spec.Enum.enum_repr_of_key'_t e -> LowParse.SLow.Base.serializer32 s'
{ "end_col": 83, "end_line": 190, "start_col": 2, "start_line": 189 }
Prims.Tot
val parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p')
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } )))
val parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') =
false
null
false
(fun (input: bytes32) -> (([@@ inline_let ]let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> (match k with | Known k' -> Some (k', consumed) | _ -> None) | _ -> None) <: (res: option (enum_key e * U32.t) {parser32_correct (parse_enum_key p e) input res})))
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Enum.enum", "Prims.unit", "Prims.eq2", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.SLow.Base.parser32", "LowParse.Spec.Enum.maybe_enum_key", "LowParse.Spec.Enum.parse_maybe_enum_key", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Enum.parse_maybe_enum_key_eq", "FStar.Bytes.reveal", "LowParse.Spec.Enum.parse_enum_key_eq" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e))
false
false
LowParse.SLow.Enum.fst
{ "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_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p')
[]
LowParse.SLow.Enum.parse32_enum_key_gen
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.parser k repr -> e: LowParse.Spec.Enum.enum key repr -> k': LowParse.Spec.Base.parser_kind -> t': Type0 -> p': LowParse.Spec.Base.parser k' t' -> u1: Prims.unit{k' == LowParse.Spec.Combinators.parse_filter_kind k} -> u15: Prims.unit{t' == LowParse.Spec.Enum.enum_key e} -> u2: Prims.unit{p' == LowParse.Spec.Enum.parse_enum_key p e} -> pe: LowParse.SLow.Base.parser32 (LowParse.Spec.Enum.parse_maybe_enum_key p e) -> LowParse.SLow.Base.parser32 p'
{ "end_col": 96, "end_line": 67, "start_col": 2, "start_line": 54 }
Prims.Tot
val size32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k == k'}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (u3: unit{s' == serialize_maybe_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (size32 s')
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k == k' } ) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (u3: unit { s' == serialize_maybe_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = size32_maybe_enum_key_gen' s32 e (size32_enum_key_gen s32 e _ _ _ (serialize_enum_key _ s e) () () () () f)
val size32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k == k'}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (u3: unit{s' == serialize_maybe_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (size32 s') let size32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k == k'}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (u3: unit{s' == serialize_maybe_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (size32 s') =
false
null
false
size32_maybe_enum_key_gen' s32 e (size32_enum_key_gen s32 e _ _ _ (serialize_enum_key _ s e) () () () () f)
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "LowParse.Spec.Enum.enum", "Prims.unit", "Prims.eq2", "LowParse.Spec.Enum.maybe_enum_key", "LowParse.Spec.Enum.parse_maybe_enum_key", "LowParse.Spec.Enum.serialize_maybe_enum_key", "LowParse.Spec.Enum.enum_repr_of_key'_t", "LowParse.SLow.Enum.size32_maybe_enum_key_gen'", "LowParse.SLow.Enum.size32_enum_key_gen", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.Spec.Enum.serialize_enum_key" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } )) inline_for_extraction let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) = serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: UInt32.t { size32_postcond (serialize_enum_key p s e) input r } )) inline_for_extraction let size32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (size32 (serialize_enum_key p s e)) = size32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let serialize32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: serializer32 (serialize_enum_key p s e)) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = fun (input: maybe_enum_key e) -> (( [@inline_let] let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@inline_let] let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r ) <: (r: bytes32 { serializer32_correct (serialize_maybe_enum_key p s e) input r } )) inline_for_extraction let serialize32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k == k' } ) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (u3: unit { s' == serialize_maybe_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = serialize32_maybe_enum_key_gen' s32 e (serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key _ s e) () () () () f) inline_for_extraction let serialize32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_maybe_enum_key p s e)) = serialize32_maybe_enum_key_gen s32 e _ _ _ (serialize_maybe_enum_key p s e) () () () () f inline_for_extraction let size32_maybe_enum_key_gen' (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (f: size32 (serialize_enum_key p s e)) : Tot (size32 (serialize_maybe_enum_key p s e)) = fun (input: maybe_enum_key e) -> (( [@inline_let] let _ = serialize_maybe_enum_key_eq s e input in match input with | Known k -> [@inline_let] let _ = serialize_enum_key_eq s e k in f k | Unknown r -> s32 r ) <: (r: U32.t { size32_postcond (serialize_maybe_enum_key p s e) input r } )) inline_for_extraction let size32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k == k' } ) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (u3: unit { s' == serialize_maybe_enum_key p s e } ) (f: enum_repr_of_key'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k == k'}) (u15: unit{t' == maybe_enum_key e}) (u2: unit{p' == parse_maybe_enum_key p e}) (u3: unit{s' == serialize_maybe_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (size32 s')
[]
LowParse.SLow.Enum.size32_maybe_enum_key_gen
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.size32 s -> e: LowParse.Spec.Enum.enum key repr -> k': LowParse.Spec.Base.parser_kind -> t': Type0 -> p': LowParse.Spec.Base.parser k' t' -> s': LowParse.Spec.Base.serializer p' -> u1: Prims.unit{k == k'} -> u15: Prims.unit{t' == LowParse.Spec.Enum.maybe_enum_key e} -> u2: Prims.unit{p' == LowParse.Spec.Enum.parse_maybe_enum_key p e} -> u3: Prims.unit{s' == LowParse.Spec.Enum.serialize_maybe_enum_key p s e} -> f: LowParse.Spec.Enum.enum_repr_of_key'_t e -> LowParse.SLow.Base.size32 s'
{ "end_col": 78, "end_line": 244, "start_col": 2, "start_line": 243 }
Prims.Tot
val size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (u3: unit{s' == serialize_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (size32 s')
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Enum", "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_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (size32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: UInt32.t { size32_postcond (serialize_enum_key p s e) input r } ))
val size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (u3: unit{s' == serialize_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (size32 s') let size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (u3: unit{s' == serialize_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (size32 s') =
false
null
false
fun (input: enum_key e) -> ([@@ inline_let ]let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: UInt32.t{size32_postcond (serialize_enum_key p s e) input r}))
{ "checked_file": "LowParse.SLow.Enum.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Enum.fst.checked", "LowParse.SLow.Combinators.fst.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Enum.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "LowParse.Spec.Enum.enum", "Prims.unit", "Prims.eq2", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Enum.parse_enum_key", "LowParse.Spec.Enum.serialize_enum_key", "LowParse.Spec.Enum.enum_repr_of_key'_t", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Enum.serialize_enum_key_eq" ]
[]
module LowParse.SLow.Enum include LowParse.Spec.Enum include LowParse.SLow.Combinators module L = FStar.List.Tot module U32 = FStar.UInt32 (* Parser for enums *) inline_for_extraction let parse32_maybe_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == k }) (u15: unit { t' == maybe_enum_key e } ) (u2: unit { p' == parse_maybe_enum_key p e } ) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 p') = parse32_synth p (maybe_enum_key_of_repr e) f p32 () inline_for_extraction let parse32_maybe_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_maybe_enum_key p e)) = parse32_maybe_enum_key_gen p32 e _ _ (parse_maybe_enum_key p e) () () () f module B32 = LowParse.Bytes32 inline_for_extraction let parse32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (p: parser k repr) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (pe: parser32 (parse_maybe_enum_key p e)) : Tot (parser32 p') = (fun (input: bytes32) -> (( [@inline_let] let _ = parse_enum_key_eq p e (B32.reveal input); parse_maybe_enum_key_eq p e (B32.reveal input) in match pe input with | Some (k, consumed) -> begin match k with | Known k' -> Some (k', consumed) | _ -> None end | _ -> None ) <: (res: option (enum_key e * U32.t) { parser32_correct (parse_enum_key p e) input res } ))) inline_for_extraction let parse32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) (f: maybe_enum_key_of_repr'_t e) : Tot (parser32 (parse_enum_key p e)) = parse32_enum_key_gen p e _ _ (parse_enum_key p e) () () () (parse32_maybe_enum_key p32 e f) inline_for_extraction let serialize32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e) : Tot (serializer32 s') = fun (input: enum_key e) -> ( [@inline_let] let _ = serialize_enum_key_eq s e input in (s32 (f input)) <: (r: bytes32 { serializer32_correct (serialize_enum_key p s e) input r } )) inline_for_extraction let serialize32_enum_key (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr) (f: enum_repr_of_key'_t e) : Tot (serializer32 (serialize_enum_key p s e)) = serialize32_enum_key_gen s32 e _ _ _ (serialize_enum_key p s e) () () () () f inline_for_extraction let size32_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k' : parser_kind) (t' : Type) (p' : parser k' t') (s' : serializer p') (u1: unit { k' == parse_filter_kind k } ) (u15: unit { t' == enum_key e } ) (u2: unit { p' == parse_enum_key p e } ) (u3: unit { s' == serialize_enum_key p s e } ) (f: enum_repr_of_key'_t e)
false
false
LowParse.SLow.Enum.fst
{ "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_enum_key_gen (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr) (k': parser_kind) (t': Type) (p': parser k' t') (s': serializer p') (u1: unit{k' == parse_filter_kind k}) (u15: unit{t' == enum_key e}) (u2: unit{p' == parse_enum_key p e}) (u3: unit{s' == serialize_enum_key p s e}) (f: enum_repr_of_key'_t e) : Tot (size32 s')
[]
LowParse.SLow.Enum.size32_enum_key_gen
{ "file_name": "src/lowparse/LowParse.SLow.Enum.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.size32 s -> e: LowParse.Spec.Enum.enum key repr -> k': LowParse.Spec.Base.parser_kind -> t': Type0 -> p': LowParse.Spec.Base.parser k' t' -> s': LowParse.Spec.Base.serializer p' -> u1: Prims.unit{k' == LowParse.Spec.Combinators.parse_filter_kind k} -> u15: Prims.unit{t' == LowParse.Spec.Enum.enum_key e} -> u2: Prims.unit{p' == LowParse.Spec.Enum.parse_enum_key p e} -> u3: Prims.unit{s' == LowParse.Spec.Enum.serialize_enum_key p s e} -> f: LowParse.Spec.Enum.enum_repr_of_key'_t e -> LowParse.SLow.Base.size32 s'
{ "end_col": 93, "end_line": 136, "start_col": 2, "start_line": 133 }
Prims.Tot
val bn_get_top_index_u32 (len: _) : bn_get_top_index_st U32 len
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "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.Lib", "short_module": "S" }, { "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_get_top_index_u32 len: bn_get_top_index_st U32 len = mk_bn_get_top_index #U32 len
val bn_get_top_index_u32 (len: _) : bn_get_top_index_st U32 len let bn_get_top_index_u32 len : bn_get_top_index_st U32 len =
false
null
false
mk_bn_get_top_index #U32 len
{ "checked_file": "Hacl.Bignum.Lib.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Lib.fst" }
[ "total" ]
[ "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Lib.mk_bn_get_top_index", "Hacl.Bignum.Lib.bn_get_top_index_st" ]
[]
module Hacl.Bignum.Lib open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions module S = Hacl.Spec.Bignum.Lib module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Get and set i-th bit of a bignum /// inline_for_extraction noextract val bn_get_ith_bit: #t:limb_t -> len:size_t -> b:lbignum t len -> i:size_t{v i / bits t < v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> h0 == h1 /\ r == S.bn_get_ith_bit (as_seq h0 b) (v i)) let bn_get_ith_bit #t len input ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); let tmp = input.(i) in (tmp >>. j) &. uint #t 1 inline_for_extraction noextract val bn_set_ith_bit: #t:limb_t -> len:size_t -> b:lbignum t len -> i:size_t{v i / bits t < v len} -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i)) let bn_set_ith_bit #t len input ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); input.(i) <- input.(i) |. (uint #t 1 <<. j) inline_for_extraction noextract val cswap2_st: #t:limb_t -> len:size_t -> bit:limb t -> b1:lbignum t len -> b2:lbignum t len -> Stack unit (requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2) (ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\ (as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2)) let cswap2_st #t len bit b1 b2 = [@inline_let] let mask = uint #t 0 -. bit in [@inline_let] let spec h0 = S.cswap2_f mask in let h0 = ST.get () in loop2 h0 len b1 b2 spec (fun i -> Loops.unfold_repeati (v len) (spec h0) (as_seq h0 b1, as_seq h0 b2) (v i); let dummy = mask &. (b1.(i) ^. b2.(i)) in b1.(i) <- b1.(i) ^. dummy; b2.(i) <- b2.(i) ^. dummy ) inline_for_extraction noextract let bn_get_top_index_st (t:limb_t) (len:size_t{0 < v len}) = b:lbignum t len -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ v r == S.bn_get_top_index (as_seq h0 b)) inline_for_extraction noextract val mk_bn_get_top_index: #t:limb_t -> len:size_t{0 < v len} -> bn_get_top_index_st t len let mk_bn_get_top_index #t len b = push_frame (); let priv = create 1ul (uint #t 0) in let h0 = ST.get () in [@ inline_let] let refl h i = v (LSeq.index (as_seq h priv) 0) in [@ inline_let] let spec h0 = S.bn_get_top_index_f (as_seq h0 b) in [@ inline_let] let inv h (i:nat{i <= v len}) = modifies1 priv h0 h /\ live h priv /\ live h b /\ disjoint priv b /\ refl h i == Loops.repeat_gen i (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0) in Loops.eq_repeat_gen0 (v len) (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0); Lib.Loops.for 0ul len inv (fun i -> Loops.unfold_repeat_gen (v len) (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0) (v i); let mask = eq_mask b.(i) (zeros t SEC) in let h1 = ST.get () in priv.(0ul) <- mask_select mask priv.(0ul) (size_to_limb i); mask_select_lemma mask (LSeq.index (as_seq h1 priv) 0) (size_to_limb i)); let res = priv.(0ul) in pop_frame (); res
false
false
Hacl.Bignum.Lib.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_get_top_index_u32 (len: _) : bn_get_top_index_st U32 len
[]
Hacl.Bignum.Lib.bn_get_top_index_u32
{ "file_name": "code/bignum/Hacl.Bignum.Lib.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} -> Hacl.Bignum.Lib.bn_get_top_index_st Lib.IntTypes.U32 len
{ "end_col": 88, "end_line": 136, "start_col": 60, "start_line": 136 }
Prims.Tot
val bn_get_bits_u64:bn_get_bits_st U64
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "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.Lib", "short_module": "S" }, { "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_get_bits_u64: bn_get_bits_st U64 = mk_bn_get_bits
val bn_get_bits_u64:bn_get_bits_st U64 let bn_get_bits_u64:bn_get_bits_st U64 =
false
null
false
mk_bn_get_bits
{ "checked_file": "Hacl.Bignum.Lib.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Lib.fst" }
[ "total" ]
[ "Hacl.Bignum.Lib.mk_bn_get_bits", "Lib.IntTypes.U64" ]
[]
module Hacl.Bignum.Lib open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions module S = Hacl.Spec.Bignum.Lib module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Get and set i-th bit of a bignum /// inline_for_extraction noextract val bn_get_ith_bit: #t:limb_t -> len:size_t -> b:lbignum t len -> i:size_t{v i / bits t < v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> h0 == h1 /\ r == S.bn_get_ith_bit (as_seq h0 b) (v i)) let bn_get_ith_bit #t len input ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); let tmp = input.(i) in (tmp >>. j) &. uint #t 1 inline_for_extraction noextract val bn_set_ith_bit: #t:limb_t -> len:size_t -> b:lbignum t len -> i:size_t{v i / bits t < v len} -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i)) let bn_set_ith_bit #t len input ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); input.(i) <- input.(i) |. (uint #t 1 <<. j) inline_for_extraction noextract val cswap2_st: #t:limb_t -> len:size_t -> bit:limb t -> b1:lbignum t len -> b2:lbignum t len -> Stack unit (requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2) (ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\ (as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2)) let cswap2_st #t len bit b1 b2 = [@inline_let] let mask = uint #t 0 -. bit in [@inline_let] let spec h0 = S.cswap2_f mask in let h0 = ST.get () in loop2 h0 len b1 b2 spec (fun i -> Loops.unfold_repeati (v len) (spec h0) (as_seq h0 b1, as_seq h0 b2) (v i); let dummy = mask &. (b1.(i) ^. b2.(i)) in b1.(i) <- b1.(i) ^. dummy; b2.(i) <- b2.(i) ^. dummy ) inline_for_extraction noextract let bn_get_top_index_st (t:limb_t) (len:size_t{0 < v len}) = b:lbignum t len -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ v r == S.bn_get_top_index (as_seq h0 b)) inline_for_extraction noextract val mk_bn_get_top_index: #t:limb_t -> len:size_t{0 < v len} -> bn_get_top_index_st t len let mk_bn_get_top_index #t len b = push_frame (); let priv = create 1ul (uint #t 0) in let h0 = ST.get () in [@ inline_let] let refl h i = v (LSeq.index (as_seq h priv) 0) in [@ inline_let] let spec h0 = S.bn_get_top_index_f (as_seq h0 b) in [@ inline_let] let inv h (i:nat{i <= v len}) = modifies1 priv h0 h /\ live h priv /\ live h b /\ disjoint priv b /\ refl h i == Loops.repeat_gen i (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0) in Loops.eq_repeat_gen0 (v len) (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0); Lib.Loops.for 0ul len inv (fun i -> Loops.unfold_repeat_gen (v len) (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0) (v i); let mask = eq_mask b.(i) (zeros t SEC) in let h1 = ST.get () in priv.(0ul) <- mask_select mask priv.(0ul) (size_to_limb i); mask_select_lemma mask (LSeq.index (as_seq h1 priv) 0) (size_to_limb i)); let res = priv.(0ul) in pop_frame (); res let bn_get_top_index_u32 len: bn_get_top_index_st U32 len = mk_bn_get_top_index #U32 len let bn_get_top_index_u64 len: bn_get_top_index_st U64 len = mk_bn_get_top_index #U64 len inline_for_extraction noextract val bn_get_top_index: #t:_ -> len:_ -> bn_get_top_index_st t len let bn_get_top_index #t = match t with | U32 -> bn_get_top_index_u32 | U64 -> bn_get_top_index_u64 inline_for_extraction noextract val bn_get_bits_limb: #t:limb_t -> len:size_t -> n:lbignum t len -> ind:size_t{v ind / bits t < v len} -> Stack (limb t) (requires fun h -> live h n) (ensures fun h0 r h1 -> h0 == h1 /\ r == S.bn_get_bits_limb (as_seq h0 n) (v ind)) let bn_get_bits_limb #t len n ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); let p1 = n.(i) >>. j in if i +! 1ul <. len && 0ul <. j then p1 |. (n.(i +! 1ul) <<. (pbits -! j)) else p1 inline_for_extraction noextract let bn_get_bits_st (t:limb_t) = len:size_t -> b:lbignum t len -> i:size_t -> l:size_t{v l < bits t /\ v i / bits t < v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> h0 == h1 /\ r == S.bn_get_bits (as_seq h0 b) (v i) (v l)) inline_for_extraction noextract val mk_bn_get_bits: #t:limb_t -> bn_get_bits_st t let mk_bn_get_bits #t len b i l = [@inline_let] let mask_l = (uint #t #SEC 1 <<. l) -. uint #t 1 in bn_get_bits_limb len b i &. mask_l [@CInline] let bn_get_bits_u32: bn_get_bits_st U32 = mk_bn_get_bits
false
true
Hacl.Bignum.Lib.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_get_bits_u64:bn_get_bits_st U64
[]
Hacl.Bignum.Lib.bn_get_bits_u64
{ "file_name": "code/bignum/Hacl.Bignum.Lib.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Bignum.Lib.bn_get_bits_st Lib.IntTypes.U64
{ "end_col": 56, "end_line": 195, "start_col": 42, "start_line": 195 }
Prims.Tot
val bn_get_top_index_u64 (len: _) : bn_get_top_index_st U64 len
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "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.Lib", "short_module": "S" }, { "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_get_top_index_u64 len: bn_get_top_index_st U64 len = mk_bn_get_top_index #U64 len
val bn_get_top_index_u64 (len: _) : bn_get_top_index_st U64 len let bn_get_top_index_u64 len : bn_get_top_index_st U64 len =
false
null
false
mk_bn_get_top_index #U64 len
{ "checked_file": "Hacl.Bignum.Lib.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Lib.fst" }
[ "total" ]
[ "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Lib.mk_bn_get_top_index", "Lib.IntTypes.U64", "Hacl.Bignum.Lib.bn_get_top_index_st" ]
[]
module Hacl.Bignum.Lib open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions module S = Hacl.Spec.Bignum.Lib module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Get and set i-th bit of a bignum /// inline_for_extraction noextract val bn_get_ith_bit: #t:limb_t -> len:size_t -> b:lbignum t len -> i:size_t{v i / bits t < v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> h0 == h1 /\ r == S.bn_get_ith_bit (as_seq h0 b) (v i)) let bn_get_ith_bit #t len input ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); let tmp = input.(i) in (tmp >>. j) &. uint #t 1 inline_for_extraction noextract val bn_set_ith_bit: #t:limb_t -> len:size_t -> b:lbignum t len -> i:size_t{v i / bits t < v len} -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i)) let bn_set_ith_bit #t len input ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); input.(i) <- input.(i) |. (uint #t 1 <<. j) inline_for_extraction noextract val cswap2_st: #t:limb_t -> len:size_t -> bit:limb t -> b1:lbignum t len -> b2:lbignum t len -> Stack unit (requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2) (ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\ (as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2)) let cswap2_st #t len bit b1 b2 = [@inline_let] let mask = uint #t 0 -. bit in [@inline_let] let spec h0 = S.cswap2_f mask in let h0 = ST.get () in loop2 h0 len b1 b2 spec (fun i -> Loops.unfold_repeati (v len) (spec h0) (as_seq h0 b1, as_seq h0 b2) (v i); let dummy = mask &. (b1.(i) ^. b2.(i)) in b1.(i) <- b1.(i) ^. dummy; b2.(i) <- b2.(i) ^. dummy ) inline_for_extraction noextract let bn_get_top_index_st (t:limb_t) (len:size_t{0 < v len}) = b:lbignum t len -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ v r == S.bn_get_top_index (as_seq h0 b)) inline_for_extraction noextract val mk_bn_get_top_index: #t:limb_t -> len:size_t{0 < v len} -> bn_get_top_index_st t len let mk_bn_get_top_index #t len b = push_frame (); let priv = create 1ul (uint #t 0) in let h0 = ST.get () in [@ inline_let] let refl h i = v (LSeq.index (as_seq h priv) 0) in [@ inline_let] let spec h0 = S.bn_get_top_index_f (as_seq h0 b) in [@ inline_let] let inv h (i:nat{i <= v len}) = modifies1 priv h0 h /\ live h priv /\ live h b /\ disjoint priv b /\ refl h i == Loops.repeat_gen i (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0) in Loops.eq_repeat_gen0 (v len) (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0); Lib.Loops.for 0ul len inv (fun i -> Loops.unfold_repeat_gen (v len) (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0) (v i); let mask = eq_mask b.(i) (zeros t SEC) in let h1 = ST.get () in priv.(0ul) <- mask_select mask priv.(0ul) (size_to_limb i); mask_select_lemma mask (LSeq.index (as_seq h1 priv) 0) (size_to_limb i)); let res = priv.(0ul) in pop_frame (); res
false
false
Hacl.Bignum.Lib.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_get_top_index_u64 (len: _) : bn_get_top_index_st U64 len
[]
Hacl.Bignum.Lib.bn_get_top_index_u64
{ "file_name": "code/bignum/Hacl.Bignum.Lib.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} -> Hacl.Bignum.Lib.bn_get_top_index_st Lib.IntTypes.U64 len
{ "end_col": 88, "end_line": 137, "start_col": 60, "start_line": 137 }
Prims.Tot
val bn_get_bits_u32:bn_get_bits_st U32
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "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.Lib", "short_module": "S" }, { "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_get_bits_u32: bn_get_bits_st U32 = mk_bn_get_bits
val bn_get_bits_u32:bn_get_bits_st U32 let bn_get_bits_u32:bn_get_bits_st U32 =
false
null
false
mk_bn_get_bits
{ "checked_file": "Hacl.Bignum.Lib.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Lib.fst" }
[ "total" ]
[ "Hacl.Bignum.Lib.mk_bn_get_bits", "Lib.IntTypes.U32" ]
[]
module Hacl.Bignum.Lib open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Base open Hacl.Bignum.Definitions module S = Hacl.Spec.Bignum.Lib module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// /// Get and set i-th bit of a bignum /// inline_for_extraction noextract val bn_get_ith_bit: #t:limb_t -> len:size_t -> b:lbignum t len -> i:size_t{v i / bits t < v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> h0 == h1 /\ r == S.bn_get_ith_bit (as_seq h0 b) (v i)) let bn_get_ith_bit #t len input ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); let tmp = input.(i) in (tmp >>. j) &. uint #t 1 inline_for_extraction noextract val bn_set_ith_bit: #t:limb_t -> len:size_t -> b:lbignum t len -> i:size_t{v i / bits t < v len} -> Stack unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i)) let bn_set_ith_bit #t len input ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); input.(i) <- input.(i) |. (uint #t 1 <<. j) inline_for_extraction noextract val cswap2_st: #t:limb_t -> len:size_t -> bit:limb t -> b1:lbignum t len -> b2:lbignum t len -> Stack unit (requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2) (ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\ (as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2)) let cswap2_st #t len bit b1 b2 = [@inline_let] let mask = uint #t 0 -. bit in [@inline_let] let spec h0 = S.cswap2_f mask in let h0 = ST.get () in loop2 h0 len b1 b2 spec (fun i -> Loops.unfold_repeati (v len) (spec h0) (as_seq h0 b1, as_seq h0 b2) (v i); let dummy = mask &. (b1.(i) ^. b2.(i)) in b1.(i) <- b1.(i) ^. dummy; b2.(i) <- b2.(i) ^. dummy ) inline_for_extraction noextract let bn_get_top_index_st (t:limb_t) (len:size_t{0 < v len}) = b:lbignum t len -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ v r == S.bn_get_top_index (as_seq h0 b)) inline_for_extraction noextract val mk_bn_get_top_index: #t:limb_t -> len:size_t{0 < v len} -> bn_get_top_index_st t len let mk_bn_get_top_index #t len b = push_frame (); let priv = create 1ul (uint #t 0) in let h0 = ST.get () in [@ inline_let] let refl h i = v (LSeq.index (as_seq h priv) 0) in [@ inline_let] let spec h0 = S.bn_get_top_index_f (as_seq h0 b) in [@ inline_let] let inv h (i:nat{i <= v len}) = modifies1 priv h0 h /\ live h priv /\ live h b /\ disjoint priv b /\ refl h i == Loops.repeat_gen i (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0) in Loops.eq_repeat_gen0 (v len) (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0); Lib.Loops.for 0ul len inv (fun i -> Loops.unfold_repeat_gen (v len) (S.bn_get_top_index_t (v len)) (spec h0) (refl h0 0) (v i); let mask = eq_mask b.(i) (zeros t SEC) in let h1 = ST.get () in priv.(0ul) <- mask_select mask priv.(0ul) (size_to_limb i); mask_select_lemma mask (LSeq.index (as_seq h1 priv) 0) (size_to_limb i)); let res = priv.(0ul) in pop_frame (); res let bn_get_top_index_u32 len: bn_get_top_index_st U32 len = mk_bn_get_top_index #U32 len let bn_get_top_index_u64 len: bn_get_top_index_st U64 len = mk_bn_get_top_index #U64 len inline_for_extraction noextract val bn_get_top_index: #t:_ -> len:_ -> bn_get_top_index_st t len let bn_get_top_index #t = match t with | U32 -> bn_get_top_index_u32 | U64 -> bn_get_top_index_u64 inline_for_extraction noextract val bn_get_bits_limb: #t:limb_t -> len:size_t -> n:lbignum t len -> ind:size_t{v ind / bits t < v len} -> Stack (limb t) (requires fun h -> live h n) (ensures fun h0 r h1 -> h0 == h1 /\ r == S.bn_get_bits_limb (as_seq h0 n) (v ind)) let bn_get_bits_limb #t len n ind = [@inline_let] let pbits = size (bits t) in let i = ind /. pbits in assert (v i == v ind / bits t); let j = ind %. pbits in assert (v j == v ind % bits t); let p1 = n.(i) >>. j in if i +! 1ul <. len && 0ul <. j then p1 |. (n.(i +! 1ul) <<. (pbits -! j)) else p1 inline_for_extraction noextract let bn_get_bits_st (t:limb_t) = len:size_t -> b:lbignum t len -> i:size_t -> l:size_t{v l < bits t /\ v i / bits t < v len} -> Stack (limb t) (requires fun h -> live h b) (ensures fun h0 r h1 -> h0 == h1 /\ r == S.bn_get_bits (as_seq h0 b) (v i) (v l)) inline_for_extraction noextract val mk_bn_get_bits: #t:limb_t -> bn_get_bits_st t let mk_bn_get_bits #t len b i l = [@inline_let] let mask_l = (uint #t #SEC 1 <<. l) -. uint #t 1 in bn_get_bits_limb len b i &. mask_l
false
true
Hacl.Bignum.Lib.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_get_bits_u32:bn_get_bits_st U32
[]
Hacl.Bignum.Lib.bn_get_bits_u32
{ "file_name": "code/bignum/Hacl.Bignum.Lib.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Bignum.Lib.bn_get_bits_st Lib.IntTypes.U32
{ "end_col": 56, "end_line": 193, "start_col": 42, "start_line": 193 }