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
val t_limbs:Hacl.Bignum.Definitions.limb_t
[ { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let t_limbs: Hacl.Bignum.Definitions.limb_t = Lib.IntTypes.U64
val t_limbs:Hacl.Bignum.Definitions.limb_t let t_limbs:Hacl.Bignum.Definitions.limb_t =
false
null
false
Lib.IntTypes.U64
{ "checked_file": "Hacl.Bignum256.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Bignum.SafeAPI.fst.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum256.fsti" }
[ "total" ]
[ "Lib.IntTypes.U64" ]
[]
module Hacl.Bignum256 open FStar.Mul module BN = Hacl.Bignum module BS = Hacl.Bignum.SafeAPI module MA = Hacl.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
true
Hacl.Bignum256.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val t_limbs:Hacl.Bignum.Definitions.limb_t
[]
Hacl.Bignum256.t_limbs
{ "file_name": "code/bignum/Hacl.Bignum256.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Bignum.Definitions.limb_t
{ "end_col": 62, "end_line": 12, "start_col": 46, "start_line": 12 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lbignum = Hacl.Bignum.Definitions.lbignum
let lbignum =
false
null
false
Hacl.Bignum.Definitions.lbignum
{ "checked_file": "Hacl.Bignum256.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Bignum.SafeAPI.fst.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum256.fsti" }
[ "total" ]
[ "Hacl.Bignum.Definitions.lbignum" ]
[]
module Hacl.Bignum256 open FStar.Mul module BN = Hacl.Bignum module BS = Hacl.Bignum.SafeAPI module MA = Hacl.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs: Hacl.Bignum.Definitions.limb_t = Lib.IntTypes.U64 inline_for_extraction noextract let n_limbs: BN.meta_len t_limbs = 4ul inline_for_extraction noextract let n_bytes = n_limbs `FStar.UInt32.mul` 8ul // A static assert that the number of bytes vs number of blocks matches. This is // important for bn_to_bytes_be which takes a number of bytes, not a number of // limbs. (It would be nice to fix this.) let _ = assert_norm (Hacl.Bignum.Definitions.blocks n_bytes 8ul = n_limbs) let _ = assert_norm (256ul = Lib.IntTypes.(size (bits t_limbs)) `FStar.UInt32.mul` n_limbs)
false
true
Hacl.Bignum256.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lbignum : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0
[]
Hacl.Bignum256.lbignum
{ "file_name": "code/bignum/Hacl.Bignum256.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0
{ "end_col": 45, "end_line": 28, "start_col": 14, "start_line": 28 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_bytes = n_limbs `FStar.UInt32.mul` 8ul
let n_bytes =
false
null
false
n_limbs `FStar.UInt32.mul` 8ul
{ "checked_file": "Hacl.Bignum256.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Bignum.SafeAPI.fst.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum256.fsti" }
[ "total" ]
[ "FStar.UInt32.mul", "Hacl.Bignum256.n_limbs", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Bignum256 open FStar.Mul module BN = Hacl.Bignum module BS = Hacl.Bignum.SafeAPI module MA = Hacl.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs: Hacl.Bignum.Definitions.limb_t = Lib.IntTypes.U64 inline_for_extraction noextract let n_limbs: BN.meta_len t_limbs = 4ul
false
true
Hacl.Bignum256.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_bytes : FStar.UInt32.t
[]
Hacl.Bignum256.n_bytes
{ "file_name": "code/bignum/Hacl.Bignum256.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.UInt32.t
{ "end_col": 44, "end_line": 18, "start_col": 14, "start_line": 18 }
Prims.Tot
val n_limbs:BN.meta_len t_limbs
[ { "abbrev": true, "full_module": "Hacl.Bignum.MontArithmetic", "short_module": "MA" }, { "abbrev": true, "full_module": "Hacl.Bignum.SafeAPI", "short_module": "BS" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_limbs: BN.meta_len t_limbs = 4ul
val n_limbs:BN.meta_len t_limbs let n_limbs:BN.meta_len t_limbs =
false
null
false
4ul
{ "checked_file": "Hacl.Bignum256.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Bignum.SafeAPI.fst.checked", "Hacl.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum256.fsti" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Bignum256 open FStar.Mul module BN = Hacl.Bignum module BS = Hacl.Bignum.SafeAPI module MA = Hacl.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs: Hacl.Bignum.Definitions.limb_t = Lib.IntTypes.U64
false
true
Hacl.Bignum256.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_limbs:BN.meta_len t_limbs
[]
Hacl.Bignum256.n_limbs
{ "file_name": "code/bignum/Hacl.Bignum256.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Bignum.meta_len Hacl.Bignum256.t_limbs
{ "end_col": 38, "end_line": 15, "start_col": 35, "start_line": 15 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let max_limb (a:alg) = maxint (limb_inttype a)
let max_limb (a: alg) =
false
null
false
maxint (limb_inttype a)
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.maxint", "Spec.Blake2.limb_inttype", "Prims.int" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val max_limb : a: Spec.Blake2.alg -> Prims.int
[]
Spec.Blake2.max_limb
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Prims.int
{ "end_col": 46, "end_line": 89, "start_col": 23, "start_line": 89 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let row_idx = n:nat {n < 4}
let row_idx =
false
null
false
n: nat{n < 4}
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16}
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val row_idx : Type0
[]
Spec.Blake2.row_idx
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 27, "end_line": 217, "start_col": 14, "start_line": 217 }
Prims.Tot
val zero_row (a: alg) : row a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let zero_row (a:alg) : row a = create 4 (zero a)
val zero_row (a: alg) : row a let zero_row (a: alg) : row a =
false
null
false
create 4 (zero a)
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.Sequence.create", "Spec.Blake2.word_t", "Spec.Blake2.zero", "Spec.Blake2.row" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val zero_row (a: alg) : row a
[]
Spec.Blake2.zero_row
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Spec.Blake2.row a
{ "end_col": 48, "end_line": 69, "start_col": 31, "start_line": 69 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12
let rounds (a: alg) =
false
null
false
match a with | Blake2S -> 10 | Blake2B -> 12
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Prims.int" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rounds : a: Spec.Blake2.alg -> Prims.int
[]
Spec.Blake2.rounds
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Prims.int
{ "end_col": 17, "end_line": 29, "start_col": 2, "start_line": 27 }
Prims.Tot
val wt (a: alg) : t: inttype{unsigned t}
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64
val wt (a: alg) : t: inttype{unsigned t} let wt (a: alg) : t: inttype{unsigned t} =
false
null
false
match a with | Blake2S -> U32 | Blake2B -> U64
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.U32", "Lib.IntTypes.U64", "Lib.IntTypes.inttype", "Prims.b2t", "Lib.IntTypes.unsigned" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val wt (a: alg) : t: inttype{unsigned t}
[]
Spec.Blake2.wt
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> t: Lib.IntTypes.inttype{Lib.IntTypes.unsigned t}
{ "end_col": 18, "end_line": 23, "start_col": 2, "start_line": 21 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64
let max_output (a: alg) =
false
null
false
match a with | Blake2S -> 32 | Blake2B -> 64
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Prims.int" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val max_output : a: Spec.Blake2.alg -> Prims.int
[]
Spec.Blake2.max_output
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Prims.int
{ "end_col": 17, "end_line": 46, "start_col": 2, "start_line": 44 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128
let limb_inttype (a: alg) =
false
null
false
match (wt a) with | U32 -> U64 | U64 -> U128
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.wt", "Lib.IntTypes.U64", "Lib.IntTypes.U128", "Lib.IntTypes.inttype" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val limb_inttype : a: Spec.Blake2.alg -> Lib.IntTypes.inttype
[]
Spec.Blake2.limb_inttype
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Lib.IntTypes.inttype
{ "end_col": 15, "end_line": 54, "start_col": 2, "start_line": 52 }
Prims.Tot
val size_ivTable:size_nat
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_ivTable : size_nat = 8
val size_ivTable:size_nat let size_ivTable:size_nat =
false
null
false
8
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_ivTable:size_nat
[]
Spec.Blake2.size_ivTable
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{n <= Prims.pow2 32 - 1}
{ "end_col": 53, "end_line": 36, "start_col": 52, "start_line": 36 }
Prims.Tot
val size_word (a: alg) : size_nat
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_word (a:alg) : size_nat = numbytes (wt a)
val size_word (a: alg) : size_nat let size_word (a: alg) : size_nat =
false
null
false
numbytes (wt a)
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.numbytes", "Spec.Blake2.wt", "Lib.IntTypes.size_nat" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_word (a: alg) : size_nat
[]
Spec.Blake2.size_word
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Lib.IntTypes.size_nat
{ "end_col": 72, "end_line": 34, "start_col": 57, "start_line": 34 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64
let max_key (a: alg) =
false
null
false
match a with | Blake2S -> 32 | Blake2B -> 64
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Prims.int" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val max_key : a: Spec.Blake2.alg -> Prims.int
[]
Spec.Blake2.max_key
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Prims.int
{ "end_col": 17, "end_line": 42, "start_col": 2, "start_line": 40 }
Prims.Tot
val list_iv_B:List.Tot.llist (uint_t U64 PUB) 8
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l
val list_iv_B:List.Tot.llist (uint_t U64 PUB) 8 let list_iv_B:List.Tot.llist (uint_t U64 PUB) 8 =
false
null
false
[@@ inline_let ]let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL ] in assert_norm (List.Tot.length l == 8); l
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.PUB", "Prims.list", "Prims.Cons", "FStar.UInt64.__uint_to_t", "Prims.Nil" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val list_iv_B:List.Tot.llist (uint_t U64 PUB) 8
[]
Spec.Blake2.list_iv_B
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.List.Tot.Properties.llist (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.PUB) 8
{ "end_col": 3, "end_line": 159, "start_col": 2, "start_line": 152 }
Prims.Tot
val list_iv_S:List.Tot.llist (uint_t U32 PUB) 8
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l
val list_iv_S:List.Tot.llist (uint_t U32 PUB) 8 let list_iv_S:List.Tot.llist (uint_t U32 PUB) 8 =
false
null
false
[@@ inline_let ]let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul ] in assert_norm (List.Tot.length l == 8); l
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.list", "Prims.Cons", "FStar.UInt32.__uint_to_t", "Prims.Nil" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val list_iv_S:List.Tot.llist (uint_t U32 PUB) 8
[]
Spec.Blake2.list_iv_S
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.List.Tot.Properties.llist (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB) 8
{ "end_col": 3, "end_line": 147, "start_col": 2, "start_line": 142 }
Prims.Tot
val limb_to_word (a: alg) (x: limb_t a) : word_t a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x
val limb_to_word (a: alg) (x: limb_t a) : word_t a let limb_to_word (a: alg) (x: limb_t a) : word_t a =
false
null
false
match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.limb_t", "Spec.Blake2.wt", "Lib.IntTypes.to_u32", "Spec.Blake2.limb_inttype", "Lib.IntTypes.SEC", "Lib.IntTypes.to_u64", "Spec.Blake2.word_t" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val limb_to_word (a: alg) (x: limb_t a) : word_t a
[]
Spec.Blake2.limb_to_word
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> x: Spec.Blake2.limb_t a -> Spec.Blake2.word_t a
{ "end_col": 19, "end_line": 115, "start_col": 2, "start_line": 113 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rtable_t (a:alg) = lseq (rotval (wt a)) 4
let rtable_t (a: alg) =
false
null
false
lseq (rotval (wt a)) 4
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.Sequence.lseq", "Lib.IntTypes.rotval", "Spec.Blake2.wt" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rtable_t : a: Spec.Blake2.alg -> Type0
[]
Spec.Blake2.rtable_t
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Type0
{ "end_col": 52, "end_line": 117, "start_col": 30, "start_line": 117 }
Prims.Tot
val rotr (#a: alg) (r1: row a) (r: row_idx) : row a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4])
val rotr (#a: alg) (r1: row a) (r: row_idx) : row a let rotr (#a: alg) (r1: row a) (r: row_idx) : row a =
false
null
false
createi 4 (fun i -> r1.[ (i + r) % 4 ])
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.row", "Spec.Blake2.row_idx", "Lib.Sequence.createi", "Spec.Blake2.word_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.op_String_Access", "Prims.op_Modulus", "Prims.op_Addition" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rotr (#a: alg) (r1: row a) (r: row_idx) : row a
[]
Spec.Blake2.rotr
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r1: Spec.Blake2.row a -> r: Spec.Blake2.row_idx -> Spec.Blake2.row a
{ "end_col": 35, "end_line": 233, "start_col": 2, "start_line": 233 }
Prims.Tot
val blake2_compress0: a:alg -> m:block_s a -> block_w a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_compress0 a m = uints_from_bytes_le m
val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m =
false
null
false
uints_from_bytes_le m
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.block_s", "Lib.ByteSequence.uints_from_bytes_le", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Spec.Blake2.size_block_w", "Spec.Blake2.block_w" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_compress0: a:alg -> m:block_s a -> block_w a
[]
Spec.Blake2.blake2_compress0
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> m: Spec.Blake2.block_s a -> Spec.Blake2.block_w a
{ "end_col": 23, "end_line": 316, "start_col": 2, "start_line": 316 }
Prims.Tot
val size_block (a: alg) : size_nat
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_block (a:alg) : size_nat = size_block_w * (size_word a)
val size_block (a: alg) : size_nat let size_block (a: alg) : size_nat =
false
null
false
size_block_w * (size_word a)
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "FStar.Mul.op_Star", "Spec.Blake2.size_block_w", "Spec.Blake2.size_word", "Lib.IntTypes.size_nat" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_block (a: alg) : size_nat
[]
Spec.Blake2.size_block
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Lib.IntTypes.size_nat
{ "end_col": 86, "end_line": 35, "start_col": 58, "start_line": 35 }
Prims.Tot
val size_hash_w:size_nat
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_hash_w : size_nat = 8
val size_hash_w:size_nat let size_hash_w:size_nat =
false
null
false
8
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_hash_w:size_nat
[]
Spec.Blake2.size_hash_w
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{n <= Prims.pow2 32 - 1}
{ "end_col": 52, "end_line": 32, "start_col": 51, "start_line": 32 }
Prims.Tot
val g1 (a: alg) (wv: state a) (i j: row_idx) (r: rotval (wt a)) : Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r
val g1 (a: alg) (wv: state a) (i j: row_idx) (r: rotval (wt a)) : Tot (state a) let g1 (a: alg) (wv: state a) (i j: row_idx) (r: rotval (wt a)) : Tot (state a) =
false
null
false
wv.[ i ] <- (wv.[ i ] ^| wv.[ j ]) >>>| r
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Spec.Blake2.row_idx", "Lib.IntTypes.rotval", "Spec.Blake2.wt", "Lib.Sequence.op_String_Assignment", "Spec.Blake2.row", "Spec.Blake2.op_Greater_Greater_Greater_Bar", "Spec.Blake2.op_Hat_Bar", "Lib.Sequence.op_String_Access" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val g1 (a: alg) (wv: state a) (i j: row_idx) (r: rotval (wt a)) : Tot (state a)
[]
Spec.Blake2.g1
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> wv: Spec.Blake2.state a -> i: Spec.Blake2.row_idx -> j: Spec.Blake2.row_idx -> r: Lib.IntTypes.rotval (Spec.Blake2.wt a) -> Spec.Blake2.state a
{ "end_col": 37, "end_line": 238, "start_col": 2, "start_line": 238 }
Prims.Tot
val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag
val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s =
false
null
false
let offset = nat_to_limb a totlen in blake2_compress a s d offset flag
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Prims.bool", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Blake2.max_limb", "Spec.Blake2.block_s", "Spec.Blake2.state", "Spec.Blake2.blake2_compress", "Spec.Blake2.limb_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Spec.Blake2.wt", "Lib.IntTypes.U64", "Lib.IntTypes.U128", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Spec.Blake2.nat_to_limb" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a)
[]
Spec.Blake2.blake2_update_block
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> flag: Prims.bool -> totlen: Prims.nat{totlen <= Spec.Blake2.max_limb a} -> d: Spec.Blake2.block_s a -> s_iv: Spec.Blake2.state a -> Spec.Blake2.state a
{ "end_col": 35, "end_line": 383, "start_col": 43, "start_line": 381 }
Prims.Tot
val op_Hat_Bar (#a: alg) (r1 r2: row a) : row a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2
val op_Hat_Bar (#a: alg) (r1 r2: row a) : row a let op_Hat_Bar (#a: alg) (r1 r2: row a) : row a =
false
null
false
map2 ( ^. ) r1 r2
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.row", "Lib.Sequence.map2", "Spec.Blake2.word_t", "Lib.IntTypes.op_Hat_Dot", "Spec.Blake2.wt", "Lib.IntTypes.SEC" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Hat_Bar (#a: alg) (r1 r2: row a) : row a
[]
Spec.Blake2.op_Hat_Bar
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r1: Spec.Blake2.row a -> r2: Spec.Blake2.row a -> Spec.Blake2.row a
{ "end_col": 19, "end_line": 221, "start_col": 2, "start_line": 221 }
Prims.Tot
val blake2: a:alg -> d:bytes -> kk:size_nat{kk <= max_key a /\ (if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2 a d kk k nn = let s = blake2_init_hash a kk nn in let s = blake2_update a kk k d s in blake2_finish a s nn
val blake2: a:alg -> d:bytes -> kk:size_nat{kk <= max_key a /\ (if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn) let blake2 a d kk k nn =
false
null
false
let s = blake2_init_hash a kk nn in let s = blake2_update a kk k d s in blake2_finish a s nn
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.ByteSequence.bytes", "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Blake2.max_key", "Prims.op_Equality", "Prims.int", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Blake2.max_limb", "Prims.bool", "Prims.op_Addition", "Spec.Blake2.size_block", "Prims.logical", "Lib.ByteSequence.lbytes", "Spec.Blake2.max_output", "Spec.Blake2.blake2_finish", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Spec.Blake2.blake2_update", "Spec.Blake2.blake2_init_hash" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a) let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block let blake2_update_last a prev rem m s = let inlen = length m in let totlen = prev + inlen in let last_block = get_last_padded_block a m rem in blake2_update_block a true totlen last_block s val blake2_update_blocks: a:alg -> prev:nat -> m:bytes{prev + length m <= max_limb a} -> s:state a -> Tot (state a) let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in nb * size_block a + rem == len} = UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len let blake2_update_blocks a prev m s = let (nb,rem) = split a (length m) in let s = repeati nb (blake2_update1 a prev m) s in blake2_update_last a prev rem m s val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a) let blake2_init_hash a kk nn = let iv0 = secret (ivTable a).[0] in let iv1 = secret (ivTable a).[1] in let iv2 = secret (ivTable a).[2] in let iv3 = secret (ivTable a).[3] in let iv4 = secret (ivTable a).[4] in let iv5 = secret (ivTable a).[5] in let iv6 = secret (ivTable a).[6] in let iv7 = secret (ivTable a).[7] in let r0 = create_row #a iv0 iv1 iv2 iv3 in let r1 = create_row #a iv4 iv5 iv6 iv7 in let s0' = (nat_to_word a 0x01010000) ^. ((nat_to_word a kk) <<. (size 8)) ^. (nat_to_word a nn) in let iv0' = iv0 ^. s0' in let r0' = create_row #a iv0' iv1 iv2 iv3 in let s_iv = createL [r0';r1;r0;r1] in s_iv val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> block_s a let blake2_key_block a kk k = let key_block = create (size_block a) (u8 0) in let key_block = update_sub key_block 0 kk k in key_block /// This function must be called only if the key is non empty (see the precondition) val blake2_update_key: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> ll:nat -> s:state a -> Tot (state a) let blake2_update_key a kk k ll s = let key_block = blake2_key_block a kk k in if ll = 0 then blake2_update_block a true (size_block a) key_block s else blake2_update_block a false (size_block a) key_block s val blake2_update: a:alg -> kk:size_nat{kk <= max_key a} -> k:lbytes kk -> d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a} -> s:state a -> Tot (state a) let blake2_update a kk k d s = let ll = length d in if kk > 0 then let s = blake2_update_key a kk k ll s in if ll = 0 then s // Skip update_last if ll = 0 (but kk > 0) else blake2_update_blocks a (size_block a) d s else blake2_update_blocks a 0 d s val blake2_finish: a:alg -> s:state a -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn) let blake2_finish a s nn = let full = (uints_to_bytes_le s.[0] @| uints_to_bytes_le s.[1]) in sub full 0 nn val blake2: a:alg -> d:bytes -> kk:size_nat{kk <= max_key a /\ (if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2: a:alg -> d:bytes -> kk:size_nat{kk <= max_key a /\ (if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn)
[]
Spec.Blake2.blake2
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> d: Lib.ByteSequence.bytes -> kk: Lib.IntTypes.size_nat { kk <= Spec.Blake2.max_key a /\ (match kk = 0 with | true -> Lib.Sequence.length d <= Spec.Blake2.max_limb a | _ -> Lib.Sequence.length d + Spec.Blake2.size_block a <= Spec.Blake2.max_limb a) } -> k: Lib.ByteSequence.lbytes kk -> nn: Lib.IntTypes.size_nat{1 <= nn /\ nn <= Spec.Blake2.max_output a} -> Lib.ByteSequence.lbytes nn
{ "end_col": 22, "end_line": 524, "start_col": 24, "start_line": 521 }
Prims.Tot
val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv
val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m =
false
null
false
repeati (rounds a) (blake2_round a m) wv
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Spec.Blake2.block_w", "Lib.LoopCombinators.repeati", "Spec.Blake2.rounds", "Spec.Blake2.blake2_round" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a)
[]
Spec.Blake2.blake2_compress2
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> wv: Spec.Blake2.state a -> m: Spec.Blake2.block_w a -> Spec.Blake2.state a
{ "end_col": 70, "end_line": 344, "start_col": 30, "start_line": 344 }
Prims.Tot
val nat_to_word (a: alg) (x: size_nat) : word_t a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x
val nat_to_word (a: alg) (x: size_nat) : word_t a let nat_to_word (a: alg) (x: size_nat) : word_t a =
false
null
false
match (wt a) with | U32 -> u32 x | U64 -> u64 x
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.size_nat", "Spec.Blake2.wt", "Lib.IntTypes.u32", "Lib.IntTypes.u64", "Spec.Blake2.word_t" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat_to_word (a: alg) (x: size_nat) : word_t a
[]
Spec.Blake2.nat_to_word
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> x: Lib.IntTypes.size_nat -> Spec.Blake2.word_t a
{ "end_col": 16, "end_line": 95, "start_col": 2, "start_line": 93 }
Prims.Tot
val size_block_w:size_nat
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_block_w : size_nat = 16
val size_block_w:size_nat let size_block_w:size_nat =
false
null
false
16
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_block_w:size_nat
[]
Spec.Blake2.size_block_w
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{n <= Prims.pow2 32 - 1}
{ "end_col": 54, "end_line": 33, "start_col": 52, "start_line": 33 }
Prims.Tot
val zero (a: alg) : word_t a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0
val zero (a: alg) : word_t a let zero (a: alg) : word_t a =
false
null
false
match a with | Blake2S -> u32 0 | Blake2B -> u64 0
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.u32", "Lib.IntTypes.u64", "Spec.Blake2.word_t" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val zero (a: alg) : word_t a
[]
Spec.Blake2.zero
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Spec.Blake2.word_t a
{ "end_col": 20, "end_line": 63, "start_col": 2, "start_line": 61 }
Prims.Tot
val sigmaTable:lseq sigma_elt_t size_sigmaTable
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma
val sigmaTable:lseq sigma_elt_t size_sigmaTable let sigmaTable:lseq sigma_elt_t size_sigmaTable =
false
null
false
assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Lib.Sequence.of_list", "Spec.Blake2.sigma_elt_t", "Spec.Blake2.list_sigma", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.nat", "FStar.List.Tot.Base.length", "Spec.Blake2.size_sigmaTable" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction
false
true
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sigmaTable:lseq sigma_elt_t size_sigmaTable
[]
Spec.Blake2.sigmaTable
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq Spec.Blake2.sigma_elt_t Spec.Blake2.size_sigmaTable
{ "end_col": 20, "end_line": 209, "start_col": 2, "start_line": 208 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let row (a:alg) = lseq (word_t a) 4
let row (a: alg) =
false
null
false
lseq (word_t a) 4
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.Sequence.lseq", "Spec.Blake2.word_t" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val row : a: Spec.Blake2.alg -> Type0
[]
Spec.Blake2.row
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Type0
{ "end_col": 42, "end_line": 66, "start_col": 25, "start_line": 66 }
Prims.Tot
val blake2_update: a:alg -> kk:size_nat{kk <= max_key a} -> k:lbytes kk -> d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a} -> s:state a -> Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_update a kk k d s = let ll = length d in if kk > 0 then let s = blake2_update_key a kk k ll s in if ll = 0 then s // Skip update_last if ll = 0 (but kk > 0) else blake2_update_blocks a (size_block a) d s else blake2_update_blocks a 0 d s
val blake2_update: a:alg -> kk:size_nat{kk <= max_key a} -> k:lbytes kk -> d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a} -> s:state a -> Tot (state a) let blake2_update a kk k d s =
false
null
false
let ll = length d in if kk > 0 then let s = blake2_update_key a kk k ll s in if ll = 0 then s else blake2_update_blocks a (size_block a) d s else blake2_update_blocks a 0 d s
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Blake2.max_key", "Lib.ByteSequence.lbytes", "Lib.ByteSequence.bytes", "Prims.op_Equality", "Prims.int", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Blake2.max_limb", "Prims.bool", "Prims.op_Addition", "Spec.Blake2.size_block", "Spec.Blake2.state", "Prims.op_GreaterThan", "Spec.Blake2.blake2_update_blocks", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Spec.Blake2.blake2_update_key", "Prims.nat" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a) let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block let blake2_update_last a prev rem m s = let inlen = length m in let totlen = prev + inlen in let last_block = get_last_padded_block a m rem in blake2_update_block a true totlen last_block s val blake2_update_blocks: a:alg -> prev:nat -> m:bytes{prev + length m <= max_limb a} -> s:state a -> Tot (state a) let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in nb * size_block a + rem == len} = UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len let blake2_update_blocks a prev m s = let (nb,rem) = split a (length m) in let s = repeati nb (blake2_update1 a prev m) s in blake2_update_last a prev rem m s val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a) let blake2_init_hash a kk nn = let iv0 = secret (ivTable a).[0] in let iv1 = secret (ivTable a).[1] in let iv2 = secret (ivTable a).[2] in let iv3 = secret (ivTable a).[3] in let iv4 = secret (ivTable a).[4] in let iv5 = secret (ivTable a).[5] in let iv6 = secret (ivTable a).[6] in let iv7 = secret (ivTable a).[7] in let r0 = create_row #a iv0 iv1 iv2 iv3 in let r1 = create_row #a iv4 iv5 iv6 iv7 in let s0' = (nat_to_word a 0x01010000) ^. ((nat_to_word a kk) <<. (size 8)) ^. (nat_to_word a nn) in let iv0' = iv0 ^. s0' in let r0' = create_row #a iv0' iv1 iv2 iv3 in let s_iv = createL [r0';r1;r0;r1] in s_iv val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> block_s a let blake2_key_block a kk k = let key_block = create (size_block a) (u8 0) in let key_block = update_sub key_block 0 kk k in key_block /// This function must be called only if the key is non empty (see the precondition) val blake2_update_key: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> ll:nat -> s:state a -> Tot (state a) let blake2_update_key a kk k ll s = let key_block = blake2_key_block a kk k in if ll = 0 then blake2_update_block a true (size_block a) key_block s else blake2_update_block a false (size_block a) key_block s val blake2_update: a:alg -> kk:size_nat{kk <= max_key a} -> k:lbytes kk -> d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a} -> s:state a ->
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_update: a:alg -> kk:size_nat{kk <= max_key a} -> k:lbytes kk -> d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a} -> s:state a -> Tot (state a)
[]
Spec.Blake2.blake2_update
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> kk: Lib.IntTypes.size_nat{kk <= Spec.Blake2.max_key a} -> k: Lib.ByteSequence.lbytes kk -> d: Lib.ByteSequence.bytes { (match kk = 0 with | true -> Lib.Sequence.length d <= Spec.Blake2.max_limb a | _ -> Lib.Sequence.length d + Spec.Blake2.size_block a <= Spec.Blake2.max_limb a) <: Type0 } -> s: Spec.Blake2.state a -> Spec.Blake2.state a
{ "end_col": 35, "end_line": 501, "start_col": 30, "start_line": 495 }
Prims.Tot
val gather_row (#a: alg) (m: block_w a) (i0 i1 i2 i3: sigma_elt_t) : row a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3]
val gather_row (#a: alg) (m: block_w a) (i0 i1 i2 i3: sigma_elt_t) : row a let gather_row (#a: alg) (m: block_w a) (i0 i1 i2 i3: sigma_elt_t) : row a =
false
null
false
create_row m.[ v i0 ] m.[ v i1 ] m.[ v i2 ] m.[ v i3 ]
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.block_w", "Spec.Blake2.sigma_elt_t", "Spec.Blake2.create_row", "Lib.Sequence.op_String_Access", "Spec.Blake2.word_t", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Blake2.row" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gather_row (#a: alg) (m: block_w a) (i0 i1 i2 i3: sigma_elt_t) : row a
[]
Spec.Blake2.gather_row
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Spec.Blake2.block_w a -> i0: Spec.Blake2.sigma_elt_t -> i1: Spec.Blake2.sigma_elt_t -> i2: Spec.Blake2.sigma_elt_t -> i3: Spec.Blake2.sigma_elt_t -> Spec.Blake2.row a
{ "end_col": 48, "end_line": 284, "start_col": 2, "start_line": 284 }
Prims.Tot
val g2 (a: alg) (wv: state a) (i j: row_idx) (x: row a) : Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x)
val g2 (a: alg) (wv: state a) (i j: row_idx) (x: row a) : Tot (state a) let g2 (a: alg) (wv: state a) (i j: row_idx) (x: row a) : Tot (state a) =
false
null
false
wv.[ i ] <- (wv.[ i ] +| wv.[ j ] +| x)
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Spec.Blake2.row_idx", "Spec.Blake2.row", "Lib.Sequence.op_String_Assignment", "Spec.Blake2.op_Plus_Bar", "Lib.Sequence.op_String_Access" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val g2 (a: alg) (wv: state a) (i j: row_idx) (x: row a) : Tot (state a)
[]
Spec.Blake2.g2
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> wv: Spec.Blake2.state a -> i: Spec.Blake2.row_idx -> j: Spec.Blake2.row_idx -> x: Spec.Blake2.row a -> Spec.Blake2.state a
{ "end_col": 35, "end_line": 241, "start_col": 2, "start_line": 241 }
Prims.Tot
val g2z (a: alg) (wv: state a) (i j: row_idx) : Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j])
val g2z (a: alg) (wv: state a) (i j: row_idx) : Tot (state a) let g2z (a: alg) (wv: state a) (i j: row_idx) : Tot (state a) =
false
null
false
wv.[ i ] <- (wv.[ i ] +| wv.[ j ])
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Spec.Blake2.row_idx", "Lib.Sequence.op_String_Assignment", "Spec.Blake2.row", "Spec.Blake2.op_Plus_Bar", "Lib.Sequence.op_String_Access" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val g2z (a: alg) (wv: state a) (i j: row_idx) : Tot (state a)
[]
Spec.Blake2.g2z
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> wv: Spec.Blake2.state a -> i: Spec.Blake2.row_idx -> j: Spec.Blake2.row_idx -> Spec.Blake2.state a
{ "end_col": 30, "end_line": 244, "start_col": 2, "start_line": 244 }
Prims.Tot
val op_Greater_Greater_Greater_Bar (#a: alg) (r1: row a) (r: rotval (wt a)) : row a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1
val op_Greater_Greater_Greater_Bar (#a: alg) (r1: row a) (r: rotval (wt a)) : row a let op_Greater_Greater_Greater_Bar (#a: alg) (r1: row a) (r: rotval (wt a)) : row a =
false
null
false
map #(word_t a) (rotate_right_i r) r1
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.row", "Lib.IntTypes.rotval", "Spec.Blake2.wt", "Lib.Sequence.map", "Spec.Blake2.word_t", "Lib.IntTypes.rotate_right_i", "Lib.IntTypes.SEC" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Greater_Greater_Greater_Bar (#a: alg) (r1: row a) (r: rotval (wt a)) : row a
[]
Spec.Blake2.op_Greater_Greater_Greater_Bar
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r1: Spec.Blake2.row a -> r: Lib.IntTypes.rotval (Spec.Blake2.wt a) -> Spec.Blake2.row a
{ "end_col": 39, "end_line": 229, "start_col": 2, "start_line": 229 }
Prims.Tot
val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv
val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y =
false
null
false
let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[ 0 ] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[ 1 ] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[ 2 ] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[ 3 ] in wv
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Spec.Blake2.row", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Spec.Blake2.g1", "Lib.Sequence.op_String_Access", "Lib.IntTypes.rotval", "Spec.Blake2.g2z", "Spec.Blake2.g2", "Spec.Blake2.rTable", "Prims.int" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a)
[]
Spec.Blake2.blake2_mixing
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> ws: Spec.Blake2.state a -> x: Spec.Blake2.row a -> y: Spec.Blake2.row a -> Spec.Blake2.state a
{ "end_col": 4, "end_line": 268, "start_col": 29, "start_line": 254 }
Prims.Tot
val blake2_update_key: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> ll:nat -> s:state a -> Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_update_key a kk k ll s = let key_block = blake2_key_block a kk k in if ll = 0 then blake2_update_block a true (size_block a) key_block s else blake2_update_block a false (size_block a) key_block s
val blake2_update_key: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> ll:nat -> s:state a -> Tot (state a) let blake2_update_key a kk k ll s =
false
null
false
let key_block = blake2_key_block a kk k in if ll = 0 then blake2_update_block a true (size_block a) key_block s else blake2_update_block a false (size_block a) key_block s
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Spec.Blake2.max_key", "Lib.ByteSequence.lbytes", "Prims.nat", "Spec.Blake2.state", "Prims.op_Equality", "Prims.int", "Spec.Blake2.blake2_update_block", "Spec.Blake2.size_block", "Prims.bool", "Spec.Blake2.block_s", "Spec.Blake2.blake2_key_block" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a) let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block let blake2_update_last a prev rem m s = let inlen = length m in let totlen = prev + inlen in let last_block = get_last_padded_block a m rem in blake2_update_block a true totlen last_block s val blake2_update_blocks: a:alg -> prev:nat -> m:bytes{prev + length m <= max_limb a} -> s:state a -> Tot (state a) let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in nb * size_block a + rem == len} = UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len let blake2_update_blocks a prev m s = let (nb,rem) = split a (length m) in let s = repeati nb (blake2_update1 a prev m) s in blake2_update_last a prev rem m s val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a) let blake2_init_hash a kk nn = let iv0 = secret (ivTable a).[0] in let iv1 = secret (ivTable a).[1] in let iv2 = secret (ivTable a).[2] in let iv3 = secret (ivTable a).[3] in let iv4 = secret (ivTable a).[4] in let iv5 = secret (ivTable a).[5] in let iv6 = secret (ivTable a).[6] in let iv7 = secret (ivTable a).[7] in let r0 = create_row #a iv0 iv1 iv2 iv3 in let r1 = create_row #a iv4 iv5 iv6 iv7 in let s0' = (nat_to_word a 0x01010000) ^. ((nat_to_word a kk) <<. (size 8)) ^. (nat_to_word a nn) in let iv0' = iv0 ^. s0' in let r0' = create_row #a iv0' iv1 iv2 iv3 in let s_iv = createL [r0';r1;r0;r1] in s_iv val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> block_s a let blake2_key_block a kk k = let key_block = create (size_block a) (u8 0) in let key_block = update_sub key_block 0 kk k in key_block /// This function must be called only if the key is non empty (see the precondition) val blake2_update_key: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> ll:nat -> s:state a ->
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_update_key: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> ll:nat -> s:state a -> Tot (state a)
[]
Spec.Blake2.blake2_update_key
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> kk: Lib.IntTypes.size_nat{0 < kk /\ kk <= Spec.Blake2.max_key a} -> k: Lib.ByteSequence.lbytes kk -> ll: Prims.nat -> s: Spec.Blake2.state a -> Spec.Blake2.state a
{ "end_col": 60, "end_line": 486, "start_col": 35, "start_line": 481 }
Prims.Tot
val get_last_padded_block (a: alg) (m: bytes) (rem: nat{rem <= length m /\ rem <= size_block a}) : block_s a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block
val get_last_padded_block (a: alg) (m: bytes) (rem: nat{rem <= length m /\ rem <= size_block a}) : block_s a let get_last_padded_block (a: alg) (m: bytes) (rem: nat{rem <= length m /\ rem <= size_block a}) : block_s a =
false
null
false
let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.ByteSequence.bytes", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Blake2.size_block", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Prims.eq2", "Lib.Sequence.sub", "Prims.l_Forall", "Prims.l_or", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Sequence.update_sub", "FStar.Seq.Base.seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_imp", "Lib.Sequence.create", "Lib.IntTypes.u8", "FStar.Seq.Base.slice", "Prims.op_Subtraction", "Spec.Blake2.block_s" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_last_padded_block (a: alg) (m: bytes) (rem: nat{rem <= length m /\ rem <= size_block a}) : block_s a
[]
Spec.Blake2.get_last_padded_block
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> m: Lib.ByteSequence.bytes -> rem: Prims.nat{rem <= Lib.Sequence.length m /\ rem <= Spec.Blake2.size_block a} -> Spec.Blake2.block_s a
{ "end_col": 12, "end_line": 414, "start_col": 67, "start_line": 410 }
Prims.Tot
val ivTable (a: alg) : lseq (pub_word_t a) 8
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B
val ivTable (a: alg) : lseq (pub_word_t a) 8 let ivTable (a: alg) : lseq (pub_word_t a) 8 =
false
null
false
match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Blake2.list_iv_S", "Lib.IntTypes.U64", "Spec.Blake2.list_iv_B", "Lib.Sequence.lseq", "Spec.Blake2.pub_word_t" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ivTable (a: alg) : lseq (pub_word_t a) 8
[]
Spec.Blake2.ivTable
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Lib.Sequence.lseq (Spec.Blake2.pub_word_t a) 8
{ "end_col": 32, "end_line": 172, "start_col": 2, "start_line": 170 }
Prims.Tot
val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> block_s a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_key_block a kk k = let key_block = create (size_block a) (u8 0) in let key_block = update_sub key_block 0 kk k in key_block
val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> block_s a let blake2_key_block a kk k =
false
null
false
let key_block = create (size_block a) (u8 0) in let key_block = update_sub key_block 0 kk k in key_block
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Spec.Blake2.max_key", "Lib.ByteSequence.lbytes", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Blake2.size_block", "Prims.eq2", "Lib.Sequence.sub", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Sequence.update_sub", "Lib.IntTypes.uint_t", "FStar.Seq.Base.seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_imp", "Lib.Sequence.create", "Lib.IntTypes.u8", "Spec.Blake2.block_s" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a) let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block let blake2_update_last a prev rem m s = let inlen = length m in let totlen = prev + inlen in let last_block = get_last_padded_block a m rem in blake2_update_block a true totlen last_block s val blake2_update_blocks: a:alg -> prev:nat -> m:bytes{prev + length m <= max_limb a} -> s:state a -> Tot (state a) let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in nb * size_block a + rem == len} = UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len let blake2_update_blocks a prev m s = let (nb,rem) = split a (length m) in let s = repeati nb (blake2_update1 a prev m) s in blake2_update_last a prev rem m s val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a) let blake2_init_hash a kk nn = let iv0 = secret (ivTable a).[0] in let iv1 = secret (ivTable a).[1] in let iv2 = secret (ivTable a).[2] in let iv3 = secret (ivTable a).[3] in let iv4 = secret (ivTable a).[4] in let iv5 = secret (ivTable a).[5] in let iv6 = secret (ivTable a).[6] in let iv7 = secret (ivTable a).[7] in let r0 = create_row #a iv0 iv1 iv2 iv3 in let r1 = create_row #a iv4 iv5 iv6 iv7 in let s0' = (nat_to_word a 0x01010000) ^. ((nat_to_word a kk) <<. (size 8)) ^. (nat_to_word a nn) in let iv0' = iv0 ^. s0' in let r0' = create_row #a iv0' iv1 iv2 iv3 in let s_iv = createL [r0';r1;r0;r1] in s_iv val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> block_s a
[]
Spec.Blake2.blake2_key_block
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> kk: Lib.IntTypes.size_nat{0 < kk /\ kk <= Spec.Blake2.max_key a} -> k: Lib.ByteSequence.lbytes kk -> Spec.Blake2.block_s a
{ "end_col": 11, "end_line": 471, "start_col": 29, "start_line": 468 }
Prims.Tot
val word_to_limb (a: alg) (x: word_t a {uint_v x <= max_limb a}) : xl: limb_t a {uint_v xl == uint_v x}
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x
val word_to_limb (a: alg) (x: word_t a {uint_v x <= max_limb a}) : xl: limb_t a {uint_v xl == uint_v x} let word_to_limb (a: alg) (x: word_t a {uint_v x <= max_limb a}) : xl: limb_t a {uint_v xl == uint_v x} =
false
null
false
match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.word_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.uint_v", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Spec.Blake2.max_limb", "Lib.IntTypes.to_u64", "Lib.IntTypes.to_u128", "Spec.Blake2.limb_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Spec.Blake2.limb_inttype" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val word_to_limb (a: alg) (x: word_t a {uint_v x <= max_limb a}) : xl: limb_t a {uint_v xl == uint_v x}
[]
Spec.Blake2.word_to_limb
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> x: Spec.Blake2.word_t a {Lib.IntTypes.uint_v x <= Spec.Blake2.max_limb a} -> xl: Spec.Blake2.limb_t a {Lib.IntTypes.uint_v xl == Lib.IntTypes.uint_v x}
{ "end_col": 20, "end_line": 109, "start_col": 2, "start_line": 107 }
Prims.Tot
val blake2b: d:bytes -> kk:size_nat{kk <= 64 /\ (if kk = 0 then length d < pow2 128 else length d + 128 < pow2 128)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= 64} -> Tot (lbytes nn)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b d kk k n = blake2 Blake2B d kk k n
val blake2b: d:bytes -> kk:size_nat{kk <= 64 /\ (if kk = 0 then length d < pow2 128 else length d + 128 < pow2 128)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= 64} -> Tot (lbytes nn) let blake2b d kk k n =
false
null
false
blake2 Blake2B d kk k n
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Lib.ByteSequence.bytes", "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "Prims.int", "Prims.op_LessThan", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.pow2", "Prims.bool", "Prims.op_Addition", "Prims.logical", "Lib.ByteSequence.lbytes", "Spec.Blake2.blake2", "Spec.Blake2.Blake2B" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a) let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block let blake2_update_last a prev rem m s = let inlen = length m in let totlen = prev + inlen in let last_block = get_last_padded_block a m rem in blake2_update_block a true totlen last_block s val blake2_update_blocks: a:alg -> prev:nat -> m:bytes{prev + length m <= max_limb a} -> s:state a -> Tot (state a) let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in nb * size_block a + rem == len} = UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len let blake2_update_blocks a prev m s = let (nb,rem) = split a (length m) in let s = repeati nb (blake2_update1 a prev m) s in blake2_update_last a prev rem m s val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a) let blake2_init_hash a kk nn = let iv0 = secret (ivTable a).[0] in let iv1 = secret (ivTable a).[1] in let iv2 = secret (ivTable a).[2] in let iv3 = secret (ivTable a).[3] in let iv4 = secret (ivTable a).[4] in let iv5 = secret (ivTable a).[5] in let iv6 = secret (ivTable a).[6] in let iv7 = secret (ivTable a).[7] in let r0 = create_row #a iv0 iv1 iv2 iv3 in let r1 = create_row #a iv4 iv5 iv6 iv7 in let s0' = (nat_to_word a 0x01010000) ^. ((nat_to_word a kk) <<. (size 8)) ^. (nat_to_word a nn) in let iv0' = iv0 ^. s0' in let r0' = create_row #a iv0' iv1 iv2 iv3 in let s_iv = createL [r0';r1;r0;r1] in s_iv val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> block_s a let blake2_key_block a kk k = let key_block = create (size_block a) (u8 0) in let key_block = update_sub key_block 0 kk k in key_block /// This function must be called only if the key is non empty (see the precondition) val blake2_update_key: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> ll:nat -> s:state a -> Tot (state a) let blake2_update_key a kk k ll s = let key_block = blake2_key_block a kk k in if ll = 0 then blake2_update_block a true (size_block a) key_block s else blake2_update_block a false (size_block a) key_block s val blake2_update: a:alg -> kk:size_nat{kk <= max_key a} -> k:lbytes kk -> d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a} -> s:state a -> Tot (state a) let blake2_update a kk k d s = let ll = length d in if kk > 0 then let s = blake2_update_key a kk k ll s in if ll = 0 then s // Skip update_last if ll = 0 (but kk > 0) else blake2_update_blocks a (size_block a) d s else blake2_update_blocks a 0 d s val blake2_finish: a:alg -> s:state a -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn) let blake2_finish a s nn = let full = (uints_to_bytes_le s.[0] @| uints_to_bytes_le s.[1]) in sub full 0 nn val blake2: a:alg -> d:bytes -> kk:size_nat{kk <= max_key a /\ (if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn) let blake2 a d kk k nn = let s = blake2_init_hash a kk nn in let s = blake2_update a kk k d s in blake2_finish a s nn val blake2s: d:bytes -> kk:size_nat{kk <= 32 /\ (if kk = 0 then length d < pow2 64 else length d + 64 < pow2 64)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= 32} -> Tot (lbytes nn) let blake2s d kk k n = blake2 Blake2S d kk k n val blake2b: d:bytes -> kk:size_nat{kk <= 64 /\ (if kk = 0 then length d < pow2 128 else length d + 128 < pow2 128)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= 64} -> Tot (lbytes nn)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b: d:bytes -> kk:size_nat{kk <= 64 /\ (if kk = 0 then length d < pow2 128 else length d + 128 < pow2 128)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= 64} -> Tot (lbytes nn)
[]
Spec.Blake2.blake2b
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d: Lib.ByteSequence.bytes -> kk: Lib.IntTypes.size_nat { kk <= 64 /\ (match kk = 0 with | true -> Lib.Sequence.length d < Prims.pow2 128 | _ -> Lib.Sequence.length d + 128 < Prims.pow2 128) } -> k: Lib.ByteSequence.lbytes kk -> nn: Lib.IntTypes.size_nat{1 <= nn /\ nn <= 64} -> Lib.ByteSequence.lbytes nn
{ "end_col": 46, "end_line": 543, "start_col": 23, "start_line": 543 }
Prims.Tot
val get_blocki (a: alg) (m: bytes) (i: nat{i < length m / size_block a}) : block_s a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a)
val get_blocki (a: alg) (m: bytes) (i: nat{i < length m / size_block a}) : block_s a let get_blocki (a: alg) (m: bytes) (i: nat{i < length m / size_block a}) : block_s a =
false
null
false
Seq.slice m (i * size_block a) ((i + 1) * size_block a)
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.ByteSequence.bytes", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Blake2.size_block", "FStar.Seq.Base.slice", "FStar.Mul.op_Star", "Prims.op_Addition", "Spec.Blake2.block_s" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_blocki (a: alg) (m: bytes) (i: nat{i < length m / size_block a}) : block_s a
[]
Spec.Blake2.get_blocki
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> m: Lib.ByteSequence.bytes -> i: Prims.nat{i < Lib.Sequence.length m / Spec.Blake2.size_block a} -> Spec.Blake2.block_s a
{ "end_col": 55, "end_line": 394, "start_col": 2, "start_line": 394 }
Prims.Tot
val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv
val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag =
false
null
false
let wv:state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[ 3 ] <- wv.[ 3 ] ^| mask in wv
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Spec.Blake2.limb_t", "Prims.bool", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Spec.Blake2.op_Hat_Bar", "Lib.Sequence.index", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_LessThan", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Lib.Sequence.op_String_Access", "Spec.Blake2.create_row", "Spec.Blake2.zero", "Lib.IntTypes.ones", "Spec.Blake2.word_t", "Spec.Blake2.limb_to_word", "Lib.IntTypes.shift_right", "Spec.Blake2.limb_inttype", "Lib.IntTypes.size", "Lib.IntTypes.bits" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a)
[]
Spec.Blake2.blake2_compress1
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> s_iv: Spec.Blake2.state a -> offset: Spec.Blake2.limb_t a -> flag: Prims.bool -> Spec.Blake2.state a
{ "end_col": 4, "end_line": 335, "start_col": 41, "start_line": 325 }
Prims.Tot
val diag (#a: alg) (wv: state a) : state a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv
val diag (#a: alg) (wv: state a) : state a let diag (#a: alg) (wv: state a) : state a =
false
null
false
let wv = wv.[ 1 ] <- rotr wv.[ 1 ] 1 in let wv = wv.[ 2 ] <- rotr wv.[ 2 ] 2 in let wv = wv.[ 3 ] <- rotr wv.[ 3 ] 3 in wv
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Spec.Blake2.rotr", "Lib.Sequence.index", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_LessThan", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Spec.Blake2.row", "Lib.Sequence.op_String_Access" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val diag (#a: alg) (wv: state a) : state a
[]
Spec.Blake2.diag
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
wv: Spec.Blake2.state a -> Spec.Blake2.state a
{ "end_col": 4, "end_line": 274, "start_col": 42, "start_line": 270 }
Prims.Tot
val size_sigmaTable:size_nat
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_sigmaTable : size_nat = 160
val size_sigmaTable:size_nat let size_sigmaTable:size_nat =
false
null
false
160
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_sigmaTable:size_nat
[]
Spec.Blake2.size_sigmaTable
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{n <= Prims.pow2 32 - 1}
{ "end_col": 58, "end_line": 37, "start_col": 55, "start_line": 37 }
Prims.Tot
val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv
val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag =
false
null
false
let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Spec.Blake2.block_s", "Spec.Blake2.limb_t", "Prims.bool", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Spec.Blake2.blake2_compress3", "Spec.Blake2.blake2_compress2", "Spec.Blake2.blake2_compress1", "Spec.Blake2.block_w", "Spec.Blake2.blake2_compress0" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a)
[]
Spec.Blake2.blake2_compress
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> s_iv: Spec.Blake2.state a -> m: Spec.Blake2.block_s a -> offset: Spec.Blake2.limb_t a -> flag: Prims.bool -> Spec.Blake2.state a
{ "end_col": 6, "end_line": 370, "start_col": 42, "start_line": 365 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let state (a:alg) = lseq (row a) 4
let state (a: alg) =
false
null
false
lseq (row a) 4
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.Sequence.lseq", "Spec.Blake2.row" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3]
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val state : a: Spec.Blake2.alg -> Type0
[]
Spec.Blake2.state
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Type0
{ "end_col": 41, "end_line": 80, "start_col": 27, "start_line": 80 }
Prims.Tot
val rTable_list_S:List.Tot.llist (rotval U32) 4
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ]
val rTable_list_S:List.Tot.llist (rotval U32) 4 let rTable_list_S:List.Tot.llist (rotval U32) 4 =
false
null
false
[size 16; size 12; size 8; size 7]
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Prims.Cons", "Lib.IntTypes.rotval", "Lib.IntTypes.U32", "Lib.IntTypes.size", "Prims.Nil" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rTable_list_S:List.Tot.llist (rotval U32) 4
[]
Spec.Blake2.rTable_list_S
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.List.Tot.Properties.llist (Lib.IntTypes.rotval Lib.IntTypes.U32) 4
{ "end_col": 3, "end_line": 124, "start_col": 2, "start_line": 122 }
Prims.Tot
val rTable_list_B:List.Tot.llist (rotval U64) 4
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ]
val rTable_list_B:List.Tot.llist (rotval U64) 4 let rTable_list_B:List.Tot.llist (rotval U64) 4 =
false
null
false
[size 32; size 24; size 16; size 63]
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Prims.Cons", "Lib.IntTypes.rotval", "Lib.IntTypes.U64", "Lib.IntTypes.size", "Prims.Nil" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rTable_list_B:List.Tot.llist (rotval U64) 4
[]
Spec.Blake2.rTable_list_B
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.List.Tot.Properties.llist (Lib.IntTypes.rotval Lib.IntTypes.U64) 4
{ "end_col": 3, "end_line": 131, "start_col": 2, "start_line": 129 }
Prims.Tot
val load_row (#a: alg) (s: lseq (word_t a) 4) : row a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]]
val load_row (#a: alg) (s: lseq (word_t a) 4) : row a let load_row (#a: alg) (s: lseq (word_t a) 4) : row a =
false
null
false
createL [s.[ 0 ]; s.[ 1 ]; s.[ 2 ]; s.[ 3 ]]
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.Sequence.lseq", "Spec.Blake2.word_t", "Lib.Sequence.createL", "Prims.Cons", "Lib.Sequence.op_String_Access", "Prims.Nil", "Spec.Blake2.row" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_row (#a: alg) (s: lseq (word_t a) 4) : row a
[]
Spec.Blake2.load_row
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Lib.Sequence.lseq (Spec.Blake2.word_t a) 4 -> Spec.Blake2.row a
{ "end_col": 38, "end_line": 73, "start_col": 2, "start_line": 73 }
Prims.Tot
val rTable (a: alg) : rtable_t a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B)
val rTable (a: alg) : rtable_t a let rTable (a: alg) : rtable_t a =
false
null
false
match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B)
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.Sequence.of_list", "Lib.IntTypes.rotval", "Lib.IntTypes.U32", "Spec.Blake2.rTable_list_S", "Lib.IntTypes.U64", "Spec.Blake2.rTable_list_B", "Spec.Blake2.rtable_t" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rTable (a: alg) : rtable_t a
[]
Spec.Blake2.rTable
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> Spec.Blake2.rtable_t a
{ "end_col": 38, "end_line": 137, "start_col": 2, "start_line": 135 }
Prims.Tot
val list_iv (a: alg) : List.Tot.llist (pub_word_t a) 8
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B
val list_iv (a: alg) : List.Tot.llist (pub_word_t a) 8 let list_iv (a: alg) : List.Tot.llist (pub_word_t a) 8 =
false
null
false
match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.list_iv_S", "Spec.Blake2.list_iv_B", "FStar.List.Tot.Properties.llist", "Spec.Blake2.pub_word_t" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val list_iv (a: alg) : List.Tot.llist (pub_word_t a) 8
[]
Spec.Blake2.list_iv
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> FStar.List.Tot.Properties.llist (Spec.Blake2.pub_word_t a) 8
{ "end_col": 24, "end_line": 166, "start_col": 2, "start_line": 164 }
Prims.Tot
val op_Plus_Bar (#a: alg) (r1 r2: row a) : row a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2
val op_Plus_Bar (#a: alg) (r1 r2: row a) : row a let op_Plus_Bar (#a: alg) (r1 r2: row a) : row a =
false
null
false
map2 ( +. ) r1 r2
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.row", "Lib.Sequence.map2", "Spec.Blake2.word_t", "Lib.IntTypes.op_Plus_Dot", "Spec.Blake2.wt", "Lib.IntTypes.SEC" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Plus_Bar (#a: alg) (r1 r2: row a) : row a
[]
Spec.Blake2.op_Plus_Bar
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r1: Spec.Blake2.row a -> r2: Spec.Blake2.row a -> Spec.Blake2.row a
{ "end_col": 19, "end_line": 225, "start_col": 2, "start_line": 225 }
Prims.Tot
val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv
val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv =
false
null
false
let start = (i % 10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[ 0 ] m_s.[ 1 ] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[ 2 ] m_s.[ 3 ] in undiag wv
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.block_w", "Lib.IntTypes.size_nat", "Spec.Blake2.state", "Spec.Blake2.undiag", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Spec.Blake2.blake2_mixing", "Lib.Sequence.op_String_Access", "Spec.Blake2.row", "Spec.Blake2.diag", "Spec.Blake2.gather_state", "Prims.int", "FStar.Mul.op_Star", "Prims.op_Modulus" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a
[]
Spec.Blake2.blake2_round
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> m: Spec.Blake2.block_w a -> i: Lib.IntTypes.size_nat -> wv: Spec.Blake2.state a -> Spec.Blake2.state a
{ "end_col": 11, "end_line": 309, "start_col": 27, "start_line": 303 }
Prims.Tot
val split (a: alg) (len: nat) : nb_rem: (nat & nat) { let nb, rem = nb_rem in nb * size_block a + rem == len }
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in nb * size_block a + rem == len} = UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len
val split (a: alg) (len: nat) : nb_rem: (nat & nat) { let nb, rem = nb_rem in nb * size_block a + rem == len } let split (a: alg) (len: nat) : nb_rem: (nat & nat) { let nb, rem = nb_rem in nb * size_block a + rem == len } =
false
null
false
UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Prims.nat", "Lib.UpdateMulti.split_at_last_lazy_nb_rem", "Spec.Blake2.size_block", "FStar.Pervasives.Native.tuple2", "Prims.eq2", "Prims.int", "Prims.op_Addition", "FStar.Mul.op_Star" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a) let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block let blake2_update_last a prev rem m s = let inlen = length m in let totlen = prev + inlen in let last_block = get_last_padded_block a m rem in blake2_update_block a true totlen last_block s val blake2_update_blocks: a:alg -> prev:nat -> m:bytes{prev + length m <= max_limb a} -> s:state a -> Tot (state a) let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val split (a: alg) (len: nat) : nb_rem: (nat & nat) { let nb, rem = nb_rem in nb * size_block a + rem == len }
[]
Spec.Blake2.split
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> len: Prims.nat -> nb_rem: (Prims.nat * Prims.nat) { let _ = nb_rem in (let FStar.Pervasives.Native.Mktuple2 #_ #_ nb rem = _ in nb * Spec.Blake2.size_block a + rem == len) <: Type0 }
{ "end_col": 58, "end_line": 432, "start_col": 2, "start_line": 432 }
Prims.Tot
val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l
val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start =
false
null
false
let x = gather_row m sigmaTable.[ start ] sigmaTable.[ start + 2 ] sigmaTable.[ start + 4 ] sigmaTable.[ start + 6 ] in let y = gather_row m sigmaTable.[ start + 1 ] sigmaTable.[ start + 3 ] sigmaTable.[ start + 5 ] sigmaTable.[ start + 7 ] in let z = gather_row m sigmaTable.[ start + 8 ] sigmaTable.[ start + 10 ] sigmaTable.[ start + 12 ] sigmaTable.[ start + 14 ] in let w = gather_row m sigmaTable.[ start + 9 ] sigmaTable.[ start + 11 ] sigmaTable.[ start + 13 ] sigmaTable.[ start + 15 ] in let l = [x; y; z; w] in assert_norm (List.Tot.length l == 4); createL l
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.block_w", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.createL", "Spec.Blake2.row", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Prims.Cons", "Prims.Nil", "Spec.Blake2.gather_row", "Lib.Sequence.op_String_Access", "Spec.Blake2.sigma_elt_t", "Spec.Blake2.size_sigmaTable", "Spec.Blake2.sigmaTable", "Prims.op_Addition", "Spec.Blake2.state" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3]
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a
[]
Spec.Blake2.gather_state
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> m: Spec.Blake2.block_w a -> start: Prims.nat{start <= 144} -> Spec.Blake2.state a
{ "end_col": 11, "end_line": 294, "start_col": 28, "start_line": 287 }
Prims.Tot
val blake2s: d:bytes -> kk:size_nat{kk <= 32 /\ (if kk = 0 then length d < pow2 64 else length d + 64 < pow2 64)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= 32} -> Tot (lbytes nn)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s d kk k n = blake2 Blake2S d kk k n
val blake2s: d:bytes -> kk:size_nat{kk <= 32 /\ (if kk = 0 then length d < pow2 64 else length d + 64 < pow2 64)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= 32} -> Tot (lbytes nn) let blake2s d kk k n =
false
null
false
blake2 Blake2S d kk k n
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Lib.ByteSequence.bytes", "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "Prims.int", "Prims.op_LessThan", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.pow2", "Prims.bool", "Prims.op_Addition", "Prims.logical", "Lib.ByteSequence.lbytes", "Spec.Blake2.blake2", "Spec.Blake2.Blake2S" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a) let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block let blake2_update_last a prev rem m s = let inlen = length m in let totlen = prev + inlen in let last_block = get_last_padded_block a m rem in blake2_update_block a true totlen last_block s val blake2_update_blocks: a:alg -> prev:nat -> m:bytes{prev + length m <= max_limb a} -> s:state a -> Tot (state a) let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in nb * size_block a + rem == len} = UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len let blake2_update_blocks a prev m s = let (nb,rem) = split a (length m) in let s = repeati nb (blake2_update1 a prev m) s in blake2_update_last a prev rem m s val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a) let blake2_init_hash a kk nn = let iv0 = secret (ivTable a).[0] in let iv1 = secret (ivTable a).[1] in let iv2 = secret (ivTable a).[2] in let iv3 = secret (ivTable a).[3] in let iv4 = secret (ivTable a).[4] in let iv5 = secret (ivTable a).[5] in let iv6 = secret (ivTable a).[6] in let iv7 = secret (ivTable a).[7] in let r0 = create_row #a iv0 iv1 iv2 iv3 in let r1 = create_row #a iv4 iv5 iv6 iv7 in let s0' = (nat_to_word a 0x01010000) ^. ((nat_to_word a kk) <<. (size 8)) ^. (nat_to_word a nn) in let iv0' = iv0 ^. s0' in let r0' = create_row #a iv0' iv1 iv2 iv3 in let s_iv = createL [r0';r1;r0;r1] in s_iv val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> block_s a let blake2_key_block a kk k = let key_block = create (size_block a) (u8 0) in let key_block = update_sub key_block 0 kk k in key_block /// This function must be called only if the key is non empty (see the precondition) val blake2_update_key: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> ll:nat -> s:state a -> Tot (state a) let blake2_update_key a kk k ll s = let key_block = blake2_key_block a kk k in if ll = 0 then blake2_update_block a true (size_block a) key_block s else blake2_update_block a false (size_block a) key_block s val blake2_update: a:alg -> kk:size_nat{kk <= max_key a} -> k:lbytes kk -> d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a} -> s:state a -> Tot (state a) let blake2_update a kk k d s = let ll = length d in if kk > 0 then let s = blake2_update_key a kk k ll s in if ll = 0 then s // Skip update_last if ll = 0 (but kk > 0) else blake2_update_blocks a (size_block a) d s else blake2_update_blocks a 0 d s val blake2_finish: a:alg -> s:state a -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn) let blake2_finish a s nn = let full = (uints_to_bytes_le s.[0] @| uints_to_bytes_le s.[1]) in sub full 0 nn val blake2: a:alg -> d:bytes -> kk:size_nat{kk <= max_key a /\ (if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn) let blake2 a d kk k nn = let s = blake2_init_hash a kk nn in let s = blake2_update a kk k d s in blake2_finish a s nn val blake2s: d:bytes -> kk:size_nat{kk <= 32 /\ (if kk = 0 then length d < pow2 64 else length d + 64 < pow2 64)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= 32} -> Tot (lbytes nn)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s: d:bytes -> kk:size_nat{kk <= 32 /\ (if kk = 0 then length d < pow2 64 else length d + 64 < pow2 64)} -> k:lbytes kk -> nn:size_nat{1 <= nn /\ nn <= 32} -> Tot (lbytes nn)
[]
Spec.Blake2.blake2s
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d: Lib.ByteSequence.bytes -> kk: Lib.IntTypes.size_nat { kk <= 32 /\ (match kk = 0 with | true -> Lib.Sequence.length d < Prims.pow2 64 | _ -> Lib.Sequence.length d + 64 < Prims.pow2 64) } -> k: Lib.ByteSequence.lbytes kk -> nn: Lib.IntTypes.size_nat{1 <= nn /\ nn <= 32} -> Lib.ByteSequence.lbytes nn
{ "end_col": 46, "end_line": 533, "start_col": 23, "start_line": 533 }
Prims.Tot
val blake2_finish: a:alg -> s:state a -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_finish a s nn = let full = (uints_to_bytes_le s.[0] @| uints_to_bytes_le s.[1]) in sub full 0 nn
val blake2_finish: a:alg -> s:state a -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn) let blake2_finish a s nn =
false
null
false
let full = (uints_to_bytes_le s.[ 0 ] @| uints_to_bytes_le s.[ 1 ]) in sub full 0 nn
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Blake2.max_output", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Addition", "FStar.Mul.op_Star", "Lib.IntTypes.numbytes", "Spec.Blake2.wt", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Prims.op_Multiply", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.append", "Lib.ByteSequence.uints_to_bytes_le", "Lib.Sequence.index", "Lib.Sequence.op_At_Bar", "Lib.Sequence.op_String_Access", "Spec.Blake2.row", "Lib.ByteSequence.lbytes" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a) let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block let blake2_update_last a prev rem m s = let inlen = length m in let totlen = prev + inlen in let last_block = get_last_padded_block a m rem in blake2_update_block a true totlen last_block s val blake2_update_blocks: a:alg -> prev:nat -> m:bytes{prev + length m <= max_limb a} -> s:state a -> Tot (state a) let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in nb * size_block a + rem == len} = UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len let blake2_update_blocks a prev m s = let (nb,rem) = split a (length m) in let s = repeati nb (blake2_update1 a prev m) s in blake2_update_last a prev rem m s val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a) let blake2_init_hash a kk nn = let iv0 = secret (ivTable a).[0] in let iv1 = secret (ivTable a).[1] in let iv2 = secret (ivTable a).[2] in let iv3 = secret (ivTable a).[3] in let iv4 = secret (ivTable a).[4] in let iv5 = secret (ivTable a).[5] in let iv6 = secret (ivTable a).[6] in let iv7 = secret (ivTable a).[7] in let r0 = create_row #a iv0 iv1 iv2 iv3 in let r1 = create_row #a iv4 iv5 iv6 iv7 in let s0' = (nat_to_word a 0x01010000) ^. ((nat_to_word a kk) <<. (size 8)) ^. (nat_to_word a nn) in let iv0' = iv0 ^. s0' in let r0' = create_row #a iv0' iv1 iv2 iv3 in let s_iv = createL [r0';r1;r0;r1] in s_iv val blake2_key_block: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> block_s a let blake2_key_block a kk k = let key_block = create (size_block a) (u8 0) in let key_block = update_sub key_block 0 kk k in key_block /// This function must be called only if the key is non empty (see the precondition) val blake2_update_key: a:alg -> kk:size_nat{0 < kk /\ kk <= max_key a} -> k:lbytes kk -> ll:nat -> s:state a -> Tot (state a) let blake2_update_key a kk k ll s = let key_block = blake2_key_block a kk k in if ll = 0 then blake2_update_block a true (size_block a) key_block s else blake2_update_block a false (size_block a) key_block s val blake2_update: a:alg -> kk:size_nat{kk <= max_key a} -> k:lbytes kk -> d:bytes{if kk = 0 then length d <= max_limb a else length d + (size_block a) <= max_limb a} -> s:state a -> Tot (state a) let blake2_update a kk k d s = let ll = length d in if kk > 0 then let s = blake2_update_key a kk k ll s in if ll = 0 then s // Skip update_last if ll = 0 (but kk > 0) else blake2_update_blocks a (size_block a) d s else blake2_update_blocks a 0 d s val blake2_finish: a:alg -> s:state a -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_finish: a:alg -> s:state a -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (lbytes nn)
[]
Spec.Blake2.blake2_finish
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> s: Spec.Blake2.state a -> nn: Lib.IntTypes.size_nat{1 <= nn /\ nn <= Spec.Blake2.max_output a} -> Lib.ByteSequence.lbytes nn
{ "end_col": 15, "end_line": 511, "start_col": 26, "start_line": 509 }
Prims.Tot
val undiag (#a: alg) (wv: state a) : state a
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv
val undiag (#a: alg) (wv: state a) : state a let undiag (#a: alg) (wv: state a) : state a =
false
null
false
let wv = wv.[ 1 ] <- rotr wv.[ 1 ] 3 in let wv = wv.[ 2 ] <- rotr wv.[ 2 ] 2 in let wv = wv.[ 3 ] <- rotr wv.[ 3 ] 1 in wv
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Spec.Blake2.rotr", "Lib.Sequence.index", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_LessThan", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Spec.Blake2.row", "Lib.Sequence.op_String_Access" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val undiag (#a: alg) (wv: state a) : state a
[]
Spec.Blake2.undiag
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
wv: Spec.Blake2.state a -> Spec.Blake2.state a
{ "end_col": 4, "end_line": 280, "start_col": 44, "start_line": 276 }
Prims.Tot
val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s
val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s =
false
null
false
let s = s.[ 0 ] <- (s.[ 0 ] ^| wv.[ 0 ]) ^| wv.[ 2 ] in let s = s.[ 1 ] <- (s.[ 1 ] ^| wv.[ 1 ]) ^| wv.[ 3 ] in s
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Spec.Blake2.state", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Spec.Blake2.op_Hat_Bar", "Lib.Sequence.index", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_LessThan", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Spec.Blake2.row", "Lib.Sequence.op_String_Access" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a)
[]
Spec.Blake2.blake2_compress3
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> wv: Spec.Blake2.state a -> s_iv: Spec.Blake2.state a -> Spec.Blake2.state a
{ "end_col": 3, "end_line": 355, "start_col": 29, "start_line": 352 }
Prims.Tot
val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a)
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2_init_hash a kk nn = let iv0 = secret (ivTable a).[0] in let iv1 = secret (ivTable a).[1] in let iv2 = secret (ivTable a).[2] in let iv3 = secret (ivTable a).[3] in let iv4 = secret (ivTable a).[4] in let iv5 = secret (ivTable a).[5] in let iv6 = secret (ivTable a).[6] in let iv7 = secret (ivTable a).[7] in let r0 = create_row #a iv0 iv1 iv2 iv3 in let r1 = create_row #a iv4 iv5 iv6 iv7 in let s0' = (nat_to_word a 0x01010000) ^. ((nat_to_word a kk) <<. (size 8)) ^. (nat_to_word a nn) in let iv0' = iv0 ^. s0' in let r0' = create_row #a iv0' iv1 iv2 iv3 in let s_iv = createL [r0';r1;r0;r1] in s_iv
val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a) let blake2_init_hash a kk nn =
false
null
false
let iv0 = secret (ivTable a).[ 0 ] in let iv1 = secret (ivTable a).[ 1 ] in let iv2 = secret (ivTable a).[ 2 ] in let iv3 = secret (ivTable a).[ 3 ] in let iv4 = secret (ivTable a).[ 4 ] in let iv5 = secret (ivTable a).[ 5 ] in let iv6 = secret (ivTable a).[ 6 ] in let iv7 = secret (ivTable a).[ 7 ] in let r0 = create_row #a iv0 iv1 iv2 iv3 in let r1 = create_row #a iv4 iv5 iv6 iv7 in let s0' = (nat_to_word a 0x01010000) ^. ((nat_to_word a kk) <<. (size 8)) ^. (nat_to_word a nn) in let iv0' = iv0 ^. s0' in let r0' = create_row #a iv0' iv1 iv2 iv3 in let s_iv = createL [r0'; r1; r0; r1] in s_iv
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Blake2.max_key", "Prims.l_and", "Spec.Blake2.max_output", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Blake2.wt", "Lib.IntTypes.SEC", "FStar.List.Tot.Base.length", "Prims.Cons", "Prims.Nil", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Properties.seq_of_list", "Lib.Sequence.createL", "Spec.Blake2.row", "Spec.Blake2.create_row", "Lib.IntTypes.op_Hat_Dot", "Spec.Blake2.nat_to_word", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.size", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Lib.Sequence.index", "Spec.Blake2.pub_word_t", "Spec.Blake2.ivTable", "Lib.IntTypes.secret", "Lib.Sequence.op_String_Access", "Spec.Blake2.state" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"] let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l inline_for_extraction let sigmaTable:lseq sigma_elt_t size_sigmaTable = assert_norm (List.Tot.length list_sigma == size_sigmaTable); of_list list_sigma (* Algorithms types *) type block_s (a:alg) = lseq uint8 (size_block a) type block_w (a:alg) = lseq (word_t a) 16 type idx_t = n:size_nat{n < 16} let row_idx = n:nat {n < 4} inline_for_extraction let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( ^. ) r1 r2 inline_for_extraction let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a = map2 ( +. ) r1 r2 inline_for_extraction let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a = map #(word_t a) (rotate_right_i r) r1 inline_for_extraction let rotr (#a:alg) (r1:row a) (r:row_idx) : row a = createi 4 (fun i -> r1.[(i+r)%4]) (* Functions *) let g1 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (r:rotval (wt a)) : Tot (state a) = wv.[i] <- (wv.[i] ^| wv.[j]) >>>| r let g2 (a:alg) (wv:state a) (i:row_idx) (j:row_idx) (x:row a) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j] +| x) let g2z (a:alg) (wv:state a) (i:row_idx) (j:row_idx) : Tot (state a) = wv.[i] <- (wv.[i] +| wv.[j]) val blake2_mixing: a:alg -> ws:state a -> row a -> row a -> Tot (state a) let blake2_mixing al wv x y = let a = 0 in let b = 1 in let c = 2 in let d = 3 in let rt = rTable al in let wv = g2 al wv a b x in let wv = g1 al wv d a rt.[0] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[1] in let wv = g2 al wv a b y in let wv = g1 al wv d a rt.[2] in let wv = g2z al wv c d in let wv = g1 al wv b c rt.[3] in wv let diag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 1 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 3 in wv let undiag (#a:alg) (wv:state a) : state a = let wv = wv.[1] <- rotr wv.[1] 3 in let wv = wv.[2] <- rotr wv.[2] 2 in let wv = wv.[3] <- rotr wv.[3] 1 in wv inline_for_extraction let gather_row (#a:alg) (m:block_w a) (i0 i1 i2 i3:sigma_elt_t) : row a = create_row m.[v i0] m.[v i1] m.[v i2] m.[v i3] val gather_state: a:alg -> m:block_w a -> start:nat{start <= 144} -> state a let gather_state a m start = let x = gather_row m sigmaTable.[start] sigmaTable.[start+2] sigmaTable.[start+4] sigmaTable.[start+6] in let y = gather_row m sigmaTable.[start+1] sigmaTable.[start+3] sigmaTable.[start+5] sigmaTable.[start+7] in let z = gather_row m sigmaTable.[start+8] sigmaTable.[start+10] sigmaTable.[start+12] sigmaTable.[start+14] in let w = gather_row m sigmaTable.[start+9] sigmaTable.[start+11] sigmaTable.[start+13] sigmaTable.[start+15] in let l = [x;y;z;w] in assert_norm (List.Tot.length l == 4); createL l val blake2_round: a:alg -> m:block_w a -> i:size_nat -> wv:state a -> state a let blake2_round a m i wv = let start = (i%10) * 16 in let m_s = gather_state a m start in let wv = blake2_mixing a wv m_s.[0] m_s.[1] in let wv = diag wv in let wv = blake2_mixing a wv m_s.[2] m_s.[3] in undiag wv val blake2_compress0: a:alg -> m:block_s a -> block_w a let blake2_compress0 a m = uints_from_bytes_le m val blake2_compress1: a:alg -> s_iv:state a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress1 a s_iv offset flag = let wv : state a = s_iv in let low_offset = limb_to_word a offset in let high_offset = limb_to_word a (shift_right #(limb_inttype a) offset (size (bits (wt a)))) in let m_12 = low_offset in let m_13 = high_offset in let m_14 = if flag then (ones (wt a) SEC) else zero a in let m_15 = zero a in let mask = create_row m_12 m_13 m_14 m_15 in let wv = wv.[3] <- wv.[3] ^| mask in wv val blake2_compress2: a:alg -> wv:state a -> m:block_w a -> Tot (state a) let blake2_compress2 a wv m = repeati (rounds a) (blake2_round a m) wv val blake2_compress3: a:alg -> wv:state a -> s_iv:state a -> Tot (state a) let blake2_compress3 a wv s = let s = s.[0] <- (s.[0] ^| wv.[0]) ^| wv.[2] in let s = s.[1] <- (s.[1] ^| wv.[1]) ^| wv.[3] in s val blake2_compress: a:alg -> s_iv:state a -> m:block_s a -> offset:limb_t a -> flag:bool -> Tot (state a) let blake2_compress a s_iv m offset flag = let m_w = blake2_compress0 a m in let wv = blake2_compress1 a s_iv offset flag in let wv = blake2_compress2 a wv m_w in let s_iv = blake2_compress3 a wv s_iv in s_iv val blake2_update_block: a:alg -> flag:bool -> totlen:nat{totlen <= max_limb a} -> d:block_s a -> s_iv:state a -> Tot (state a) let blake2_update_block a flag totlen d s = let offset = nat_to_limb a totlen in blake2_compress a s d offset flag val blake2_update1: a:alg -> prev:nat -> m:bytes -> i:nat{i < length m / size_block a /\ prev + length m <= max_limb a} -> s:state a -> Tot (state a) let get_blocki (a:alg) (m:bytes) (i:nat{i < length m / size_block a}) : block_s a = Seq.slice m (i * size_block a) ((i+1) * size_block a) let blake2_update1 a prev m i s = let totlen = prev + (i+1) * size_block a in let d = get_blocki a m i in blake2_update_block a false totlen d s val blake2_update_last: a:alg -> prev:nat -> rem:nat -> m:bytes{prev + length m <= max_limb a /\ rem <= length m /\ rem <= size_block a} -> s:state a -> Tot (state a) let get_last_padded_block (a:alg) (m:bytes) (rem:nat{rem <= length m /\ rem <= size_block a}) : block_s a = let last = Seq.slice m (length m - rem) (length m) in let last_block = create (size_block a) (u8 0) in let last_block = update_sub last_block 0 rem last in last_block let blake2_update_last a prev rem m s = let inlen = length m in let totlen = prev + inlen in let last_block = get_last_padded_block a m rem in blake2_update_block a true totlen last_block s val blake2_update_blocks: a:alg -> prev:nat -> m:bytes{prev + length m <= max_limb a} -> s:state a -> Tot (state a) let split (a:alg) (len:nat) : nb_rem:(nat & nat){let (nb,rem) = nb_rem in nb * size_block a + rem == len} = UpdateMulti.split_at_last_lazy_nb_rem (size_block a) len let blake2_update_blocks a prev m s = let (nb,rem) = split a (length m) in let s = repeati nb (blake2_update1 a prev m) s in blake2_update_last a prev rem m s val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a)
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2_init_hash: a:alg -> kk:size_nat{kk <= max_key a} -> nn:size_nat{1 <= nn /\ nn <= max_output a} -> Tot (state a)
[]
Spec.Blake2.blake2_init_hash
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> kk: Lib.IntTypes.size_nat{kk <= Spec.Blake2.max_key a} -> nn: Lib.IntTypes.size_nat{1 <= nn /\ nn <= Spec.Blake2.max_output a} -> Spec.Blake2.state a
{ "end_col": 6, "end_line": 461, "start_col": 30, "start_line": 446 }
Prims.Tot
val list_sigma:list_sigma_t
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let list_sigma: list_sigma_t = [@inline_let] let l : list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm(List.Tot.length l == 160); l
val list_sigma:list_sigma_t let list_sigma:list_sigma_t =
false
null
false
[@@ inline_let ]let l:list sigma_elt_t = [ size 0; size 1; size 2; size 3; size 4; size 5; size 6; size 7; size 8; size 9; size 10; size 11; size 12; size 13; size 14; size 15; size 14; size 10; size 4; size 8; size 9; size 15; size 13; size 6; size 1; size 12; size 0; size 2; size 11; size 7; size 5; size 3; size 11; size 8; size 12; size 0; size 5; size 2; size 15; size 13; size 10; size 14; size 3; size 6; size 7; size 1; size 9; size 4; size 7; size 9; size 3; size 1; size 13; size 12; size 11; size 14; size 2; size 6; size 5; size 10; size 4; size 0; size 15; size 8; size 9; size 0; size 5; size 7; size 2; size 4; size 10; size 15; size 14; size 1; size 11; size 12; size 6; size 8; size 3; size 13; size 2; size 12; size 6; size 10; size 0; size 11; size 8; size 3; size 4; size 13; size 7; size 5; size 15; size 14; size 1; size 9; size 12; size 5; size 1; size 15; size 14; size 13; size 4; size 10; size 0; size 7; size 6; size 3; size 9; size 2; size 8; size 11; size 13; size 11; size 7; size 14; size 12; size 1; size 3; size 9; size 5; size 0; size 15; size 4; size 8; size 6; size 2; size 10; size 6; size 15; size 14; size 9; size 11; size 3; size 0; size 8; size 12; size 2; size 13; size 7; size 1; size 4; size 10; size 5; size 10; size 2; size 8; size 4; size 7; size 6; size 1; size 5; size 15; size 11; size 9; size 14; size 3; size 12; size 13; size 0 ] in assert_norm (List.Tot.length l == 160); l
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Spec.Blake2.sigma_elt_t", "Prims.list", "Prims.Cons", "Lib.IntTypes.size", "Prims.Nil" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l inline_for_extraction let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} = match (wt a) with | U32 -> to_u64 x | U64 -> to_u128 x inline_for_extraction let limb_to_word (a:alg) (x:limb_t a) : word_t a = match (wt a) with | U32 -> to_u32 x | U64 -> to_u64 x unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4 [@"opaque_to_smt"] inline_for_extraction let rTable_list_S : List.Tot.llist (rotval U32) 4 = [ size 16; size 12; size 8; size 7 ] [@"opaque_to_smt"] inline_for_extraction let rTable_list_B: List.Tot.llist (rotval U64) 4 = [ size 32; size 24; size 16; size 63 ] inline_for_extraction let rTable (a:alg) : rtable_t a = match a with | Blake2S -> (of_list rTable_list_S) | Blake2B -> (of_list rTable_list_B) [@"opaque_to_smt"] inline_for_extraction let list_iv_S: List.Tot.llist (uint_t U32 PUB) 8 = [@inline_let] let l = [ 0x6A09E667ul; 0xBB67AE85ul; 0x3C6EF372ul; 0xA54FF53Aul; 0x510E527Ful; 0x9B05688Cul; 0x1F83D9ABul; 0x5BE0CD19ul] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv_B: List.Tot.llist (uint_t U64 PUB) 8 = [@inline_let] let l = [ 0x6A09E667F3BCC908uL; 0xBB67AE8584CAA73BuL; 0x3C6EF372FE94F82BuL; 0xA54FF53A5F1D36F1uL; 0x510E527FADE682D1uL; 0x9B05688C2B3E6C1FuL; 0x1F83D9ABFB41BD6BuL; 0x5BE0CD19137E2179uL] in assert_norm(List.Tot.length l == 8); l [@"opaque_to_smt"] inline_for_extraction let list_iv (a:alg): List.Tot.llist (pub_word_t a) 8 = match a with | Blake2S -> list_iv_S | Blake2B -> list_iv_B inline_for_extraction let ivTable (a:alg) : lseq (pub_word_t a) 8 = match a with | Blake2S -> of_list list_iv_S | Blake2B -> of_list list_iv_B type sigma_elt_t = n:size_t{size_v n < 16} type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160} [@"opaque_to_smt"]
false
true
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val list_sigma:list_sigma_t
[]
Spec.Blake2.list_sigma
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Blake2.list_sigma_t
{ "end_col": 3, "end_line": 203, "start_col": 2, "start_line": 179 }
Prims.Tot
val nat_to_limb (a: alg) (x: nat{x <= max_limb a}) : xl: limb_t a {uint_v xl == x}
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} = match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l
val nat_to_limb (a: alg) (x: nat{x <= max_limb a}) : xl: limb_t a {uint_v xl == x} let nat_to_limb (a: alg) (x: nat{x <= max_limb a}) : xl: limb_t a {uint_v xl == x} =
false
null
false
match (wt a) with | U32 -> u64 x | U64 -> let h = u64 (x / pow2 64) in let l = u64 (x % pow2 64) in (to_u128 h <<. 64ul) +! to_u128 l
{ "checked_file": "Spec.Blake2.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Blake2.fst" }
[ "total" ]
[ "Spec.Blake2.alg", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Blake2.max_limb", "Spec.Blake2.wt", "Lib.IntTypes.u64", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U128", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.to_u128", "Lib.IntTypes.U64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.v", "Prims.op_Modulus", "Prims.pow2", "Prims.op_Division", "Spec.Blake2.limb_t", "Prims.l_or", "Spec.Blake2.limb_inttype", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.uint_v" ]
[]
module Spec.Blake2 open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--z3rlimit 50" type alg = | Blake2S | Blake2B let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = () inline_for_extraction let wt (a:alg) : t:inttype{unsigned t} = match a with | Blake2S -> U32 | Blake2B -> U64 inline_for_extraction let rounds (a:alg) = match a with | Blake2S -> 10 | Blake2B -> 12 (* Algorithm parameters *) inline_for_extraction let size_hash_w : size_nat = 8 inline_for_extraction let size_block_w : size_nat = 16 inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) inline_for_extraction let size_ivTable : size_nat = 8 inline_for_extraction let size_sigmaTable : size_nat = 160 inline_for_extraction let max_key (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 inline_for_extraction let max_output (a:alg) = match a with | Blake2S -> 32 | Blake2B -> 64 (* Definition of base types *) inline_for_extraction unfold let limb_inttype (a:alg) = match (wt a) with | U32 -> U64 | U64 -> U128 inline_for_extraction unfold type word_t (a:alg) = uint_t (wt a) SEC inline_for_extraction let zero (a:alg) : word_t a= match a with | Blake2S -> u32 0 | Blake2B -> u64 0 inline_for_extraction unfold let row (a:alg) = lseq (word_t a) 4 inline_for_extraction let zero_row (a:alg) : row a = create 4 (zero a) inline_for_extraction let load_row (#a:alg) (s:lseq (word_t a) 4) : row a = createL [s.[0]; s.[1]; s.[2]; s.[3]] inline_for_extraction let create_row (#a:alg) x0 x1 x2 x3 : row a = createL [x0;x1;x2;x3] inline_for_extraction unfold let state (a:alg) = lseq (row a) 4 inline_for_extraction type pub_word_t (a:alg) = uint_t (wt a) PUB inline_for_extraction type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC inline_for_extraction let max_limb (a:alg) = maxint (limb_inttype a) inline_for_extraction let nat_to_word (a:alg) (x:size_nat) : word_t a = match (wt a) with | U32 -> u32 x | U64 -> u64 x inline_for_extraction
false
false
Spec.Blake2.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat_to_limb (a: alg) (x: nat{x <= max_limb a}) : xl: limb_t a {uint_v xl == x}
[]
Spec.Blake2.nat_to_limb
{ "file_name": "specs/Spec.Blake2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Blake2.alg -> x: Prims.nat{x <= Spec.Blake2.max_limb a} -> xl: Spec.Blake2.limb_t a {Lib.IntTypes.uint_v xl == x}
{ "end_col": 36, "end_line": 103, "start_col": 2, "start_line": 99 }
Prims.Tot
val xer_ov (xer: xer_t) : bool
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 xer_ov (xer:xer_t) : bool = S.xer_ov xer
val xer_ov (xer: xer_t) : bool let xer_ov (xer: xer_t) : bool =
false
null
false
S.xer_ov xer
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Machine_s.xer_t", "Vale.PPC64LE.Semantics_s.xer_ov", "Prims.bool" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val xer_ov (xer: xer_t) : bool
[]
Vale.PPC64LE.Lemmas.xer_ov
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
xer: Vale.PPC64LE.Machine_s.xer_t -> Prims.bool
{ "end_col": 44, "end_line": 16, "start_col": 32, "start_line": 16 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 fuel = nat
let fuel =
false
null
false
nat
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Prims.nat" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fuel : Type0
[]
Vale.PPC64LE.Lemmas.fuel
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 21, "end_line": 14, "start_col": 18, "start_line": 14 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 state_eq_opt (ignore_ghost:bool) (s1 s2:option state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2
let state_eq_opt (ignore_ghost: bool) (s1 s2: option state) =
false
null
false
match (s1, s2) with | Some s1, Some s2 -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Prims.bool", "FStar.Pervasives.Native.option", "Vale.PPC64LE.State.state", "FStar.Pervasives.Native.Mktuple2", "Vale.PPC64LE.Lemmas.state_eq_S", "FStar.Pervasives.Native.tuple2", "Prims.eq2", "Prims.logical" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer let update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov let update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca let rec code_modifies_ghost (c:code) : bool = match c with | Ins (S.Ghost _) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:state) : state = {s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2)
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val state_eq_opt : ignore_ghost: Prims.bool -> s1: FStar.Pervasives.Native.option Vale.PPC64LE.State.state -> s2: FStar.Pervasives.Native.option Vale.PPC64LE.State.state -> Prims.logical
[]
Vale.PPC64LE.Lemmas.state_eq_opt
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ignore_ghost: Prims.bool -> s1: FStar.Pervasives.Native.option Vale.PPC64LE.State.state -> s2: FStar.Pervasives.Native.option Vale.PPC64LE.State.state -> Prims.logical
{ "end_col": 17, "end_line": 44, "start_col": 2, "start_line": 42 }
Prims.Tot
val valid_ocmp (c: ocmp) (s: state) : bool
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 valid_ocmp (c:ocmp) (s:state) : bool = S.valid_ocmp c s
val valid_ocmp (c: ocmp) (s: state) : bool let valid_ocmp (c: ocmp) (s: state) : bool =
false
null
false
S.valid_ocmp c s
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Lemmas.ocmp", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Semantics_s.valid_ocmp", "Prims.bool" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer let update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov let update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca let rec code_modifies_ghost (c:code) : bool = match c with | Ins (S.Ghost _) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:state) : state = {s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:state) (f0:fuel) (s1:state) : Type0 = state_eq_opt (code_modifies_ghost c) (S.eval_code c f0 s0) (Some s1) let eval_code2 (c:code) (s0:state) (f0:fuel) (s1:state) : prop0 = Some s1 == S.eval_code c f0 s0 let eval_ins (c:code) (s0:state) : Pure (state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM ) = let f0 = 0 in let (Some sM) = S.eval_code c f0 s0 in (sM, f0) let eval_ocmp (s:state) (c:ocmp) : bool = S.eval_ocmp s c
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_ocmp (c: ocmp) (s: state) : bool
[]
Vale.PPC64LE.Lemmas.valid_ocmp
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.PPC64LE.Lemmas.ocmp -> s: Vale.PPC64LE.State.state -> Prims.bool
{ "end_col": 59, "end_line": 63, "start_col": 43, "start_line": 63 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov
let update_xer_ov (xer: xer_t) (new_xer_ov: bool) =
false
null
false
S.update_xer_ov xer new_xer_ov
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Machine_s.xer_t", "Prims.bool", "Vale.PPC64LE.Semantics_s.update_xer_ov", "Prims.eq2", "Vale.PPC64LE.Semantics_s.xer_ov" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer
false
false
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_xer_ov : xer: Vale.PPC64LE.Machine_s.xer_t -> new_xer_ov: Prims.bool -> new_xer: Vale.PPC64LE.Machine_s.xer_t{Vale.PPC64LE.Semantics_s.xer_ov new_xer == new_xer_ov}
[]
Vale.PPC64LE.Lemmas.update_xer_ov
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
xer: Vale.PPC64LE.Machine_s.xer_t -> new_xer_ov: Prims.bool -> new_xer: Vale.PPC64LE.Machine_s.xer_t{Vale.PPC64LE.Semantics_s.xer_ov new_xer == new_xer_ov}
{ "end_col": 80, "end_line": 18, "start_col": 50, "start_line": 18 }
Prims.Tot
val eval_cmp_opr (o: cmp_opr) (s: state) : nat64
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 eval_cmp_opr (o:cmp_opr) (s:state) : nat64 = S.eval_cmp_opr o s
val eval_cmp_opr (o: cmp_opr) (s: state) : nat64 let eval_cmp_opr (o: cmp_opr) (s: state) : nat64 =
false
null
false
S.eval_cmp_opr o s
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Machine_s.cmp_opr", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Semantics_s.eval_cmp_opr", "Vale.PPC64LE.Machine_s.nat64" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer let update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov let update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca let rec code_modifies_ghost (c:code) : bool = match c with | Ins (S.Ghost _) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:state) : state = {s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:state) (f0:fuel) (s1:state) : Type0 = state_eq_opt (code_modifies_ghost c) (S.eval_code c f0 s0) (Some s1) let eval_code2 (c:code) (s0:state) (f0:fuel) (s1:state) : prop0 = Some s1 == S.eval_code c f0 s0 let eval_ins (c:code) (s0:state) : Pure (state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM ) = let f0 = 0 in let (Some sM) = S.eval_code c f0 s0 in (sM, f0)
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_cmp_opr (o: cmp_opr) (s: state) : nat64
[]
Vale.PPC64LE.Lemmas.eval_cmp_opr
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.PPC64LE.Machine_s.cmp_opr -> s: Vale.PPC64LE.State.state -> Vale.PPC64LE.Machine_s.nat64
{ "end_col": 67, "end_line": 62, "start_col": 49, "start_line": 62 }
Prims.Tot
val xer_ca (xer: xer_t) : bool
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 xer_ca (xer:xer_t) : bool = S.xer_ca xer
val xer_ca (xer: xer_t) : bool let xer_ca (xer: xer_t) : bool =
false
null
false
S.xer_ca xer
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Machine_s.xer_t", "Vale.PPC64LE.Semantics_s.xer_ca", "Prims.bool" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val xer_ca (xer: xer_t) : bool
[]
Vale.PPC64LE.Lemmas.xer_ca
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
xer: Vale.PPC64LE.Machine_s.xer_t -> Prims.bool
{ "end_col": 44, "end_line": 17, "start_col": 32, "start_line": 17 }
Prims.Tot
val eval_ocmp (s: state) (c: ocmp) : bool
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 eval_ocmp (s:state) (c:ocmp) : bool = S.eval_ocmp s c
val eval_ocmp (s: state) (c: ocmp) : bool let eval_ocmp (s: state) (c: ocmp) : bool =
false
null
false
S.eval_ocmp s c
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.State.state", "Vale.PPC64LE.Lemmas.ocmp", "Vale.PPC64LE.Semantics_s.eval_ocmp", "Prims.bool" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer let update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov let update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca let rec code_modifies_ghost (c:code) : bool = match c with | Ins (S.Ghost _) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:state) : state = {s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:state) (f0:fuel) (s1:state) : Type0 = state_eq_opt (code_modifies_ghost c) (S.eval_code c f0 s0) (Some s1) let eval_code2 (c:code) (s0:state) (f0:fuel) (s1:state) : prop0 = Some s1 == S.eval_code c f0 s0 let eval_ins (c:code) (s0:state) : Pure (state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM ) = let f0 = 0 in let (Some sM) = S.eval_code c f0 s0 in (sM, f0)
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_ocmp (s: state) (c: ocmp) : bool
[]
Vale.PPC64LE.Lemmas.eval_ocmp
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.PPC64LE.State.state -> c: Vale.PPC64LE.Lemmas.ocmp -> Prims.bool
{ "end_col": 57, "end_line": 61, "start_col": 42, "start_line": 61 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 codes = S.codes
let codes =
false
null
false
S.codes
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Semantics_s.codes" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val codes : Type0
[]
Vale.PPC64LE.Lemmas.codes
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 26, "end_line": 12, "start_col": 19, "start_line": 12 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca
let update_xer_ca (xer: xer_t) (new_xer_ca: bool) =
false
null
false
S.update_xer_ca xer new_xer_ca
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Machine_s.xer_t", "Prims.bool", "Vale.PPC64LE.Semantics_s.update_xer_ca", "Prims.eq2", "Vale.PPC64LE.Semantics_s.xer_ca" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer
false
false
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_xer_ca : xer: Vale.PPC64LE.Machine_s.xer_t -> new_xer_ca: Prims.bool -> new_xer: Vale.PPC64LE.Machine_s.xer_t{Vale.PPC64LE.Semantics_s.xer_ca new_xer == new_xer_ca}
[]
Vale.PPC64LE.Lemmas.update_xer_ca
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
xer: Vale.PPC64LE.Machine_s.xer_t -> new_xer_ca: Prims.bool -> new_xer: Vale.PPC64LE.Machine_s.xer_t{Vale.PPC64LE.Semantics_s.xer_ca new_xer == new_xer_ca}
{ "end_col": 80, "end_line": 19, "start_col": 50, "start_line": 19 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 ocmp = S.ocmp
let ocmp =
false
null
false
S.ocmp
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Semantics_s.ocmp" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ocmp : Type0
[]
Vale.PPC64LE.Lemmas.ocmp
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 24, "end_line": 13, "start_col": 18, "start_line": 13 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 state_eq_S (ignore_ghost:bool) (s1 s2:state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2)
let state_eq_S (ignore_ghost: bool) (s1 s2: state) =
false
null
false
machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2)
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Prims.bool", "Vale.PPC64LE.State.state", "Vale.PPC64LE.State.machine_state_eq", "Vale.PPC64LE.Lemmas.core_state", "Prims.logical" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer let update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov let update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca let rec code_modifies_ghost (c:code) : bool = match c with | Ins (S.Ghost _) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:state) : state = {s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap; }
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val state_eq_S : ignore_ghost: Prims.bool -> s1: Vale.PPC64LE.State.state -> s2: Vale.PPC64LE.State.state -> Prims.logical
[]
Vale.PPC64LE.Lemmas.state_eq_S
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ignore_ghost: Prims.bool -> s1: Vale.PPC64LE.State.state -> s2: Vale.PPC64LE.State.state -> Prims.logical
{ "end_col": 76, "end_line": 39, "start_col": 2, "start_line": 39 }
Prims.Tot
val eval_code2 (c: code) (s0: state) (f0: fuel) (s1: state) : prop0
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 eval_code2 (c:code) (s0:state) (f0:fuel) (s1:state) : prop0 = Some s1 == S.eval_code c f0 s0
val eval_code2 (c: code) (s0: state) (f0: fuel) (s1: state) : prop0 let eval_code2 (c: code) (s0: state) (f0: fuel) (s1: state) : prop0 =
false
null
false
Some s1 == S.eval_code c f0 s0
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Lemmas.code", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Lemmas.fuel", "Prims.eq2", "FStar.Pervasives.Native.option", "Vale.PPC64LE.Machine_s.state", "FStar.Pervasives.Native.Some", "Vale.PPC64LE.Semantics_s.eval_code", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer let update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov let update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca let rec code_modifies_ghost (c:code) : bool = match c with | Ins (S.Ghost _) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:state) : state = {s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:state) (f0:fuel) (s1:state) : Type0 = state_eq_opt (code_modifies_ghost c) (S.eval_code c f0 s0) (Some s1)
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_code2 (c: code) (s0: state) (f0: fuel) (s1: state) : prop0
[]
Vale.PPC64LE.Lemmas.eval_code2
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.PPC64LE.Lemmas.code -> s0: Vale.PPC64LE.State.state -> f0: Vale.PPC64LE.Lemmas.fuel -> s1: Vale.PPC64LE.State.state -> Vale.Def.Prop_s.prop0
{ "end_col": 32, "end_line": 50, "start_col": 2, "start_line": 50 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 code = S.code
let code =
false
null
false
S.code
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Semantics_s.code" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val code : Type0
[]
Vale.PPC64LE.Lemmas.code
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 24, "end_line": 11, "start_col": 18, "start_line": 11 }
Prims.Tot
val core_state (ignore_ghost: bool) (s: state) : state
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 core_state (ignore_ghost:bool) (s:state) : state = {s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap; }
val core_state (ignore_ghost: bool) (s: state) : state let core_state (ignore_ghost: bool) (s: state) : state =
false
null
false
{ s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap }
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Prims.bool", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Machine_s.Mkstate", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ok", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__regs", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__vecs", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__cr0", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__xer", "Vale.Arch.HeapLemmas.heap_ignore_ghost_machine", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_heap", "Vale.Arch.Heap.heap_impl", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stack", "Vale.PPC64LE.Machine_s.__proj__Mkstate__item__ms_stackTaint" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer let update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov let update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca let rec code_modifies_ghost (c:code) : bool = match c with | Ins (S.Ghost _) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val core_state (ignore_ghost: bool) (s: state) : state
[]
Vale.PPC64LE.Lemmas.core_state
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ignore_ghost: Prims.bool -> s: Vale.PPC64LE.State.state -> Vale.PPC64LE.State.state
{ "end_col": 86, "end_line": 35, "start_col": 3, "start_line": 34 }
Prims.Tot
val eval_code (c: code) (s0: state) (f0: fuel) (s1: state) : Type0
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 eval_code (c:code) (s0:state) (f0:fuel) (s1:state) : Type0 = state_eq_opt (code_modifies_ghost c) (S.eval_code c f0 s0) (Some s1)
val eval_code (c: code) (s0: state) (f0: fuel) (s1: state) : Type0 let eval_code (c: code) (s0: state) (f0: fuel) (s1: state) : Type0 =
false
null
false
state_eq_opt (code_modifies_ghost c) (S.eval_code c f0 s0) (Some s1)
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Lemmas.code", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Lemmas.fuel", "Vale.PPC64LE.Lemmas.state_eq_opt", "Vale.PPC64LE.Lemmas.code_modifies_ghost", "Vale.PPC64LE.Semantics_s.eval_code", "FStar.Pervasives.Native.Some" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer let update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov let update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca let rec code_modifies_ghost (c:code) : bool = match c with | Ins (S.Ghost _) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:state) : state = {s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2
false
true
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_code (c: code) (s0: state) (f0: fuel) (s1: state) : Type0
[]
Vale.PPC64LE.Lemmas.eval_code
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.PPC64LE.Lemmas.code -> s0: Vale.PPC64LE.State.state -> f0: Vale.PPC64LE.Lemmas.fuel -> s1: Vale.PPC64LE.State.state -> Type0
{ "end_col": 70, "end_line": 47, "start_col": 2, "start_line": 47 }
Prims.Pure
val eval_ins (c: code) (s0: state) : Pure (state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM)
[ { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": 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 eval_ins (c:code) (s0:state) : Pure (state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM ) = let f0 = 0 in let (Some sM) = S.eval_code c f0 s0 in (sM, f0)
val eval_ins (c: code) (s0: state) : Pure (state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM) let eval_ins (c: code) (s0: state) : Pure (state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM) =
false
null
false
let f0 = 0 in let Some sM = S.eval_code c f0 s0 in (sM, f0)
{ "checked_file": "Vale.PPC64LE.Lemmas.fsti.checked", "dependencies": [ "Vale.PPC64LE.StateLemmas.fsti.checked", "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.PPC64LE.Lemmas.fsti" }
[]
[ "Vale.PPC64LE.Lemmas.code", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Machine_s.state", "FStar.Pervasives.Native.Mktuple2", "Vale.PPC64LE.Lemmas.fuel", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "Vale.PPC64LE.Semantics_s.eval_code", "Prims.int", "Prims.b2t", "Vale.PPC64LE.Machine_s.uu___is_Ins", "Vale.PPC64LE.Semantics_s.ins", "Vale.PPC64LE.Semantics_s.ocmp", "Vale.PPC64LE.Lemmas.eval_code" ]
[]
module Vale.PPC64LE.Lemmas open Vale.Def.Prop_s open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.StateLemmas module S = Vale.PPC64LE.Semantics_s open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas unfold let code = S.code unfold let codes = S.codes unfold let ocmp = S.ocmp unfold let fuel = nat let xer_ov (xer:xer_t) : bool = S.xer_ov xer let xer_ca (xer:xer_t) : bool = S.xer_ca xer let update_xer_ov (xer:xer_t) (new_xer_ov:bool) = S.update_xer_ov xer new_xer_ov let update_xer_ca (xer:xer_t) (new_xer_ca:bool) = S.update_xer_ca xer new_xer_ca let rec code_modifies_ghost (c:code) : bool = match c with | Ins (S.Ghost _) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:state) : state = {s with ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.ms_heap else s.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:state) (f0:fuel) (s1:state) : Type0 = state_eq_opt (code_modifies_ghost c) (S.eval_code c f0 s0) (Some s1) let eval_code2 (c:code) (s0:state) (f0:fuel) (s1:state) : prop0 = Some s1 == S.eval_code c f0 s0 let eval_ins (c:code) (s0:state) : Pure (state & fuel) (requires Ins? c) (ensures fun (sM, f0) ->
false
false
Vale.PPC64LE.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_ins (c: code) (s0: state) : Pure (state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM)
[]
Vale.PPC64LE.Lemmas.eval_ins
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.PPC64LE.Lemmas.code -> s0: Vale.PPC64LE.State.state -> Prims.Pure (Vale.PPC64LE.State.state * Vale.PPC64LE.Lemmas.fuel)
{ "end_col": 10, "end_line": 59, "start_col": 5, "start_line": 56 }
Prims.Tot
val size (x: int) (n: pos) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 size (x:int) (n:pos) : Tot Type0 = b2t(fits x n)
val size (x: int) (n: pos) : Tot Type0 let size (x: int) (n: pos) : Tot Type0 =
false
null
false
b2t (fits x n)
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.int", "Prims.pos", "Prims.b2t", "FStar.Int.fits" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1))
false
true
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size (x: int) (n: pos) : Tot Type0
[]
FStar.Int.size
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: Prims.int -> n: Prims.pos -> Type0
{ "end_col": 52, "end_line": 45, "start_col": 39, "start_line": 45 }
Prims.Tot
val fits (x: int) (n: pos) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n
val fits (x: int) (n: pos) : Tot bool let fits (x: int) (n: pos) : Tot bool =
false
null
false
min_int n <= x && x <= max_int n
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.int", "Prims.pos", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "FStar.Int.min_int", "FStar.Int.max_int", "Prims.bool" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1))
false
true
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fits (x: int) (n: pos) : Tot bool
[]
FStar.Int.fits
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: Prims.int -> n: Prims.pos -> Prims.bool
{ "end_col": 70, "end_line": 44, "start_col": 38, "start_line": 44 }
Prims.Tot
val logor (#n: pos) (a b: int_t n) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let logor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b))
val logor (#n: pos) (a b: int_t n) : Tot (int_t n) let logor (#n: pos) (a b: int_t n) : Tot (int_t n) =
false
null
false
from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b))
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "FStar.Int.from_vec", "FStar.BitVector.logor_vec", "FStar.Int.to_vec" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b let gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b let gte #n (a:int_t n) (b:int_t n) : Tot bool = a >= b let lt #n (a:int_t n) (b:int_t n) : Tot bool = a < b let lte #n (a:int_t n) (b:int_t n) : Tot bool = a <= b #push-options "--initial_fuel 1 --max_fuel 1" /// Casts let to_uint (#n:pos) (x:int_t n) : Tot (UInt.uint_t n) = if 0 <= x then x else x + pow2 n let from_uint (#n:pos) (x:UInt.uint_t n) : Tot (int_t n) = if x <= max_int n then x else x - pow2 n val to_uint_injective: #n:pos -> x:int_t n -> Lemma (ensures from_uint (to_uint x) == x) [SMTPat (to_uint x)] let to_int_t (m:pos) (a:int) : Tot (int_t m) = a @% pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) let to_vec (#n:pos) (num:int_t n) : Tot (bv_t n) = UInt.to_vec (to_uint num) let from_vec (#n:pos) (vec:bv_t n) : Tot (int_t n) = let x = UInt.from_vec vec in if max_int n < x then x - pow2 n else x val to_vec_lemma_1: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:pos -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:pos -> num:int_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n-1} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:pos{p < n-1} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:int_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val one_nth_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b))
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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 logor (#n: pos) (a b: int_t n) : Tot (int_t n)
[]
FStar.Int.logor
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n -> b: FStar.Int.int_t n -> FStar.Int.int_t n
{ "end_col": 56, "end_line": 299, "start_col": 2, "start_line": 299 }
Prims.Tot
val gt (#n: _) (a b: int_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b
val gt (#n: _) (a b: int_t n) : Tot bool let gt #n (a: int_t n) (b: int_t n) : Tot bool =
false
null
false
a > b
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "Prims.op_GreaterThan", "Prims.bool" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *)
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gt (#n: _) (a b: int_t n) : Tot bool
[]
FStar.Int.gt
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n -> b: FStar.Int.int_t n -> Prims.bool
{ "end_col": 52, "end_line": 181, "start_col": 47, "start_line": 181 }
Prims.Tot
val lt (#n: _) (a b: int_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 lt #n (a:int_t n) (b:int_t n) : Tot bool = a < b
val lt (#n: _) (a b: int_t n) : Tot bool let lt #n (a: int_t n) (b: int_t n) : Tot bool =
false
null
false
a < b
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "Prims.op_LessThan", "Prims.bool" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b let gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lt (#n: _) (a b: int_t n) : Tot bool
[]
FStar.Int.lt
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n -> b: FStar.Int.int_t n -> Prims.bool
{ "end_col": 52, "end_line": 183, "start_col": 47, "start_line": 183 }
Prims.Tot
val logand (#n: pos) (a b: int_t n) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let logand (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b))
val logand (#n: pos) (a b: int_t n) : Tot (int_t n) let logand (#n: pos) (a b: int_t n) : Tot (int_t n) =
false
null
false
from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b))
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "FStar.Int.from_vec", "FStar.BitVector.logand_vec", "FStar.Int.to_vec" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b let gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b let gte #n (a:int_t n) (b:int_t n) : Tot bool = a >= b let lt #n (a:int_t n) (b:int_t n) : Tot bool = a < b let lte #n (a:int_t n) (b:int_t n) : Tot bool = a <= b #push-options "--initial_fuel 1 --max_fuel 1" /// Casts let to_uint (#n:pos) (x:int_t n) : Tot (UInt.uint_t n) = if 0 <= x then x else x + pow2 n let from_uint (#n:pos) (x:UInt.uint_t n) : Tot (int_t n) = if x <= max_int n then x else x - pow2 n val to_uint_injective: #n:pos -> x:int_t n -> Lemma (ensures from_uint (to_uint x) == x) [SMTPat (to_uint x)] let to_int_t (m:pos) (a:int) : Tot (int_t m) = a @% pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) let to_vec (#n:pos) (num:int_t n) : Tot (bv_t n) = UInt.to_vec (to_uint num) let from_vec (#n:pos) (vec:bv_t n) : Tot (int_t n) = let x = UInt.from_vec vec in if max_int n < x then x - pow2 n else x val to_vec_lemma_1: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:pos -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:pos -> num:int_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n-1} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:pos{p < n-1} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:int_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val one_nth_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *)
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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 logand (#n: pos) (a b: int_t n) : Tot (int_t n)
[]
FStar.Int.logand
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n -> b: FStar.Int.int_t n -> FStar.Int.int_t n
{ "end_col": 57, "end_line": 293, "start_col": 2, "start_line": 293 }
Prims.Tot
val gte (#n: _) (a b: int_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 gte #n (a:int_t n) (b:int_t n) : Tot bool = a >= b
val gte (#n: _) (a b: int_t n) : Tot bool let gte #n (a: int_t n) (b: int_t n) : Tot bool =
false
null
false
a >= b
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "Prims.op_GreaterThanOrEqual", "Prims.bool" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gte (#n: _) (a b: int_t n) : Tot bool
[]
FStar.Int.gte
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n -> b: FStar.Int.int_t n -> Prims.bool
{ "end_col": 54, "end_line": 182, "start_col": 48, "start_line": 182 }
Prims.Tot
val lte (#n: _) (a b: int_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 lte #n (a:int_t n) (b:int_t n) : Tot bool = a <= b
val lte (#n: _) (a b: int_t n) : Tot bool let lte #n (a: int_t n) (b: int_t n) : Tot bool =
false
null
false
a <= b
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "Prims.op_LessThanOrEqual", "Prims.bool" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b let gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b let gte #n (a:int_t n) (b:int_t n) : Tot bool = a >= b
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lte (#n: _) (a b: int_t n) : Tot bool
[]
FStar.Int.lte
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n -> b: FStar.Int.int_t n -> Prims.bool
{ "end_col": 54, "end_line": 184, "start_col": 48, "start_line": 184 }
Prims.Tot
val logxor (#n: pos) (a b: int_t n) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let logxor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b))
val logxor (#n: pos) (a b: int_t n) : Tot (int_t n) let logxor (#n: pos) (a b: int_t n) : Tot (int_t n) =
false
null
false
from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b))
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "FStar.Int.from_vec", "FStar.BitVector.logxor_vec", "FStar.Int.to_vec" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b let gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b let gte #n (a:int_t n) (b:int_t n) : Tot bool = a >= b let lt #n (a:int_t n) (b:int_t n) : Tot bool = a < b let lte #n (a:int_t n) (b:int_t n) : Tot bool = a <= b #push-options "--initial_fuel 1 --max_fuel 1" /// Casts let to_uint (#n:pos) (x:int_t n) : Tot (UInt.uint_t n) = if 0 <= x then x else x + pow2 n let from_uint (#n:pos) (x:UInt.uint_t n) : Tot (int_t n) = if x <= max_int n then x else x - pow2 n val to_uint_injective: #n:pos -> x:int_t n -> Lemma (ensures from_uint (to_uint x) == x) [SMTPat (to_uint x)] let to_int_t (m:pos) (a:int) : Tot (int_t m) = a @% pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) let to_vec (#n:pos) (num:int_t n) : Tot (bv_t n) = UInt.to_vec (to_uint num) let from_vec (#n:pos) (vec:bv_t n) : Tot (int_t n) = let x = UInt.from_vec vec in if max_int n < x then x - pow2 n else x val to_vec_lemma_1: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:pos -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:pos -> num:int_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n-1} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:pos{p < n-1} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:int_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val one_nth_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b))
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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 logxor (#n: pos) (a b: int_t n) : Tot (int_t n)
[]
FStar.Int.logxor
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n -> b: FStar.Int.int_t n -> FStar.Int.int_t n
{ "end_col": 57, "end_line": 296, "start_col": 2, "start_line": 296 }
Prims.Tot
val lognot (#n: pos) (a: int_t n) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lognot (#n:pos) (a:int_t n) : Tot (int_t n)= from_vec #n (lognot_vec #n (to_vec #n a))
val lognot (#n: pos) (a: int_t n) : Tot (int_t n) let lognot (#n: pos) (a: int_t n) : Tot (int_t n) =
false
null
false
from_vec #n (lognot_vec #n (to_vec #n a))
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "FStar.Int.from_vec", "FStar.BitVector.lognot_vec", "FStar.Int.to_vec" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b let gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b let gte #n (a:int_t n) (b:int_t n) : Tot bool = a >= b let lt #n (a:int_t n) (b:int_t n) : Tot bool = a < b let lte #n (a:int_t n) (b:int_t n) : Tot bool = a <= b #push-options "--initial_fuel 1 --max_fuel 1" /// Casts let to_uint (#n:pos) (x:int_t n) : Tot (UInt.uint_t n) = if 0 <= x then x else x + pow2 n let from_uint (#n:pos) (x:UInt.uint_t n) : Tot (int_t n) = if x <= max_int n then x else x - pow2 n val to_uint_injective: #n:pos -> x:int_t n -> Lemma (ensures from_uint (to_uint x) == x) [SMTPat (to_uint x)] let to_int_t (m:pos) (a:int) : Tot (int_t m) = a @% pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) let to_vec (#n:pos) (num:int_t n) : Tot (bv_t n) = UInt.to_vec (to_uint num) let from_vec (#n:pos) (vec:bv_t n) : Tot (int_t n) = let x = UInt.from_vec vec in if max_int n < x then x - pow2 n else x val to_vec_lemma_1: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:pos -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:pos -> num:int_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n-1} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:pos{p < n-1} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:int_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val one_nth_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b))
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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 lognot (#n: pos) (a: int_t n) : Tot (int_t n)
[]
FStar.Int.lognot
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n -> FStar.Int.int_t n
{ "end_col": 43, "end_line": 302, "start_col": 2, "start_line": 302 }
Prims.Tot
val shift_right (#n: pos) (a: int_t n {0 <= a}) (s: nat) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let shift_right (#n:pos) (a:int_t n{0 <= a}) (s:nat) : Tot (int_t n) = from_vec (shift_right_vec #n (to_vec #n a) s)
val shift_right (#n: pos) (a: int_t n {0 <= a}) (s: nat) : Tot (int_t n) let shift_right (#n: pos) (a: int_t n {0 <= a}) (s: nat) : Tot (int_t n) =
false
null
false
from_vec (shift_right_vec #n (to_vec #n a) s)
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.nat", "FStar.Int.from_vec", "FStar.BitVector.shift_right_vec", "FStar.Int.to_vec" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b let gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b let gte #n (a:int_t n) (b:int_t n) : Tot bool = a >= b let lt #n (a:int_t n) (b:int_t n) : Tot bool = a < b let lte #n (a:int_t n) (b:int_t n) : Tot bool = a <= b #push-options "--initial_fuel 1 --max_fuel 1" /// Casts let to_uint (#n:pos) (x:int_t n) : Tot (UInt.uint_t n) = if 0 <= x then x else x + pow2 n let from_uint (#n:pos) (x:UInt.uint_t n) : Tot (int_t n) = if x <= max_int n then x else x - pow2 n val to_uint_injective: #n:pos -> x:int_t n -> Lemma (ensures from_uint (to_uint x) == x) [SMTPat (to_uint x)] let to_int_t (m:pos) (a:int) : Tot (int_t m) = a @% pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) let to_vec (#n:pos) (num:int_t n) : Tot (bv_t n) = UInt.to_vec (to_uint num) let from_vec (#n:pos) (vec:bv_t n) : Tot (int_t n) = let x = UInt.from_vec vec in if max_int n < x then x - pow2 n else x val to_vec_lemma_1: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:pos -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:pos -> num:int_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n-1} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:pos{p < n-1} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:int_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val one_nth_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:int_t n) : Tot (int_t n)= from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:int_t n -> b:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:int_t n -> b:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:int_t n -> b:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos{1 < n}) (a:int_t n) : Tot (int_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:int_t n -> b:int_t n -> c:int_t n -> Lemma (logand #n (logand #n a b) c = logand #n a (logand #n b c)) val logand_self: #n:pos -> a:int_t n -> Lemma (logand #n a a = a) val logand_lemma_1: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:int_t n -> Lemma (logand #n a (ones n) = a) val sign_bit_negative: #n:pos{1 < n} -> a:int_t n -> Lemma (nth a 0 = true <==> a < 0) val sign_bit_positive: #n:pos{1 < n} -> a:int_t n -> Lemma (nth a 0 = false <==> 0 <= a) val logand_pos_le: #n:pos{1 < n} -> a:int_t n{0 <= a} -> b:int_t n{0 <= b} -> Lemma (0 <= logand a b /\ logand a b <= a /\ logand a b <= b) val logand_pow2_minus_one: #n:pos{1 < n} -> a:int_t n -> m:pos{m < n} -> Lemma (0 <= logand a (pow2_minus_one m) /\ logand a (pow2_minus_one m) <= pow2_minus_one #n m) val logand_max: #n:pos{1 < n} -> a:int_t n{0 <= a} -> Lemma (0 <= logand a (max_int n) /\ a = logand a (max_int n)) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:int_t n -> b:int_t n -> c:int_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) val logxor_inv: #n:pos -> a:int_t n -> b:int_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:int_t n -> b:int_t n -> Lemma (a <> b ==> logxor a b <> 0) val lognot_negative: #n:pos -> a:int_t n -> Lemma (requires a < 0) (ensures lognot a == UInt.lognot #n (a + pow2 n)) (* Shift operators *) (** If a is negative the result is undefined behaviour *) let shift_left (#n:pos) (a:int_t n{0 <= a}) (s:nat) : Tot (int_t n) = from_vec (shift_left_vec #n (to_vec #n a) s) (** If a is negative the result is implementation defined *)
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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 shift_right (#n: pos) (a: int_t n {0 <= a}) (s: nat) : Tot (int_t n)
[]
FStar.Int.shift_right
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n {0 <= a} -> s: Prims.nat -> FStar.Int.int_t n
{ "end_col": 47, "end_line": 398, "start_col": 2, "start_line": 398 }
Prims.Tot
val shift_left (#n: pos) (a: int_t n {0 <= a}) (s: nat) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let shift_left (#n:pos) (a:int_t n{0 <= a}) (s:nat) : Tot (int_t n) = from_vec (shift_left_vec #n (to_vec #n a) s)
val shift_left (#n: pos) (a: int_t n {0 <= a}) (s: nat) : Tot (int_t n) let shift_left (#n: pos) (a: int_t n {0 <= a}) (s: nat) : Tot (int_t n) =
false
null
false
from_vec (shift_left_vec #n (to_vec #n a) s)
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.nat", "FStar.Int.from_vec", "FStar.BitVector.shift_left_vec", "FStar.Int.to_vec" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b let gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b let gte #n (a:int_t n) (b:int_t n) : Tot bool = a >= b let lt #n (a:int_t n) (b:int_t n) : Tot bool = a < b let lte #n (a:int_t n) (b:int_t n) : Tot bool = a <= b #push-options "--initial_fuel 1 --max_fuel 1" /// Casts let to_uint (#n:pos) (x:int_t n) : Tot (UInt.uint_t n) = if 0 <= x then x else x + pow2 n let from_uint (#n:pos) (x:UInt.uint_t n) : Tot (int_t n) = if x <= max_int n then x else x - pow2 n val to_uint_injective: #n:pos -> x:int_t n -> Lemma (ensures from_uint (to_uint x) == x) [SMTPat (to_uint x)] let to_int_t (m:pos) (a:int) : Tot (int_t m) = a @% pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) let to_vec (#n:pos) (num:int_t n) : Tot (bv_t n) = UInt.to_vec (to_uint num) let from_vec (#n:pos) (vec:bv_t n) : Tot (int_t n) = let x = UInt.from_vec vec in if max_int n < x then x - pow2 n else x val to_vec_lemma_1: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:pos -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:pos -> num:int_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n-1} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:pos{p < n-1} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:int_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val one_nth_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:int_t n) : Tot (int_t n)= from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:int_t n -> b:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:int_t n -> b:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:int_t n -> b:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos{1 < n}) (a:int_t n) : Tot (int_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:int_t n -> b:int_t n -> c:int_t n -> Lemma (logand #n (logand #n a b) c = logand #n a (logand #n b c)) val logand_self: #n:pos -> a:int_t n -> Lemma (logand #n a a = a) val logand_lemma_1: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:int_t n -> Lemma (logand #n a (ones n) = a) val sign_bit_negative: #n:pos{1 < n} -> a:int_t n -> Lemma (nth a 0 = true <==> a < 0) val sign_bit_positive: #n:pos{1 < n} -> a:int_t n -> Lemma (nth a 0 = false <==> 0 <= a) val logand_pos_le: #n:pos{1 < n} -> a:int_t n{0 <= a} -> b:int_t n{0 <= b} -> Lemma (0 <= logand a b /\ logand a b <= a /\ logand a b <= b) val logand_pow2_minus_one: #n:pos{1 < n} -> a:int_t n -> m:pos{m < n} -> Lemma (0 <= logand a (pow2_minus_one m) /\ logand a (pow2_minus_one m) <= pow2_minus_one #n m) val logand_max: #n:pos{1 < n} -> a:int_t n{0 <= a} -> Lemma (0 <= logand a (max_int n) /\ a = logand a (max_int n)) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:int_t n -> b:int_t n -> c:int_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) val logxor_inv: #n:pos -> a:int_t n -> b:int_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:int_t n -> b:int_t n -> Lemma (a <> b ==> logxor a b <> 0) val lognot_negative: #n:pos -> a:int_t n -> Lemma (requires a < 0) (ensures lognot a == UInt.lognot #n (a + pow2 n)) (* Shift operators *) (** If a is negative the result is undefined behaviour *)
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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 shift_left (#n: pos) (a: int_t n {0 <= a}) (s: nat) : Tot (int_t n)
[]
FStar.Int.shift_left
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n {0 <= a} -> s: Prims.nat -> FStar.Int.int_t n
{ "end_col": 46, "end_line": 394, "start_col": 2, "start_line": 394 }
Prims.Tot
val shift_arithmetic_right (#n: pos) (a: int_t n) (s: nat) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let shift_arithmetic_right (#n:pos) (a:int_t n) (s:nat) : Tot (int_t n) = from_vec (shift_arithmetic_right_vec #n (to_vec #n a) s)
val shift_arithmetic_right (#n: pos) (a: int_t n) (s: nat) : Tot (int_t n) let shift_arithmetic_right (#n: pos) (a: int_t n) (s: nat) : Tot (int_t n) =
false
null
false
from_vec (shift_arithmetic_right_vec #n (to_vec #n a) s)
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.Int.int_t", "Prims.nat", "FStar.Int.from_vec", "FStar.BitVector.shift_arithmetic_right_vec", "FStar.Int.to_vec" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options let ones (n:pos) : Tot (int_t n) = -1 (* Increment and decrement *) let incr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:pos) (a:int_t n) : Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:pos -> a:int_t n -> Pure (int_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a + 1) % (pow2 (n-1)) let decr_mod (#n:pos) (a:int_t n) : Tot (int_t n) = (a - 1) % (pow2 (n-1)) (* Addition primitives *) let add (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) #push-options "--initial_fuel 1 --max_fuel 1" let add_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a + b) @% (pow2 n) (* Subtraction primitives *) let sub (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a - b) @% (pow2 n) (* Multiplication primitives *) let mul (#n:pos) (a:int_t n) (b:int_t n) : Pure (int_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:pos -> a:int_t n -> b:int_t n -> Pure (int_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = (a * b) @% (pow2 n) #pop-options (* Division primitives *) let div (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Pure (int_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:pos -> a:int_t n -> b:int_t n{b <> 0} -> Pure (int_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:int_t n{min_int n < a} -> b:int_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:int_t n{min_int n < a}) (b:int_t n{b <> 0}) : Tot (c:int_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:pos) (a:int_t n) (b:int_t n{b <> 0}) : Tot (int_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:int_t n) (b:int_t n) : Tot bool = a = b let gt #n (a:int_t n) (b:int_t n) : Tot bool = a > b let gte #n (a:int_t n) (b:int_t n) : Tot bool = a >= b let lt #n (a:int_t n) (b:int_t n) : Tot bool = a < b let lte #n (a:int_t n) (b:int_t n) : Tot bool = a <= b #push-options "--initial_fuel 1 --max_fuel 1" /// Casts let to_uint (#n:pos) (x:int_t n) : Tot (UInt.uint_t n) = if 0 <= x then x else x + pow2 n let from_uint (#n:pos) (x:UInt.uint_t n) : Tot (int_t n) = if x <= max_int n then x else x - pow2 n val to_uint_injective: #n:pos -> x:int_t n -> Lemma (ensures from_uint (to_uint x) == x) [SMTPat (to_uint x)] let to_int_t (m:pos) (a:int) : Tot (int_t m) = a @% pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) let to_vec (#n:pos) (num:int_t n) : Tot (bv_t n) = UInt.to_vec (to_uint num) let from_vec (#n:pos) (vec:bv_t n) : Tot (int_t n) = let x = UInt.from_vec vec in if max_int n < x then x - pow2 n else x val to_vec_lemma_1: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:pos -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:pos -> num:int_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n-1} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:pos{p < n-1} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:int_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val one_nth_lemma: #n:pos{1 < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:int_t n) (b:int_t n) : Tot (int_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:int_t n) : Tot (int_t n)= from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:int_t n -> b:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:int_t n -> b:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:int_t n -> b:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:int_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos{1 < n}) (a:int_t n) : Tot (int_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:int_t n -> b:int_t n -> c:int_t n -> Lemma (logand #n (logand #n a b) c = logand #n a (logand #n b c)) val logand_self: #n:pos -> a:int_t n -> Lemma (logand #n a a = a) val logand_lemma_1: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:int_t n -> Lemma (logand #n a (ones n) = a) val sign_bit_negative: #n:pos{1 < n} -> a:int_t n -> Lemma (nth a 0 = true <==> a < 0) val sign_bit_positive: #n:pos{1 < n} -> a:int_t n -> Lemma (nth a 0 = false <==> 0 <= a) val logand_pos_le: #n:pos{1 < n} -> a:int_t n{0 <= a} -> b:int_t n{0 <= b} -> Lemma (0 <= logand a b /\ logand a b <= a /\ logand a b <= b) val logand_pow2_minus_one: #n:pos{1 < n} -> a:int_t n -> m:pos{m < n} -> Lemma (0 <= logand a (pow2_minus_one m) /\ logand a (pow2_minus_one m) <= pow2_minus_one #n m) val logand_max: #n:pos{1 < n} -> a:int_t n{0 <= a} -> Lemma (0 <= logand a (max_int n) /\ a = logand a (max_int n)) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:int_t n -> b:int_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:int_t n -> b:int_t n -> c:int_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:int_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) val logxor_inv: #n:pos -> a:int_t n -> b:int_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:int_t n -> b:int_t n -> Lemma (a <> b ==> logxor a b <> 0) val lognot_negative: #n:pos -> a:int_t n -> Lemma (requires a < 0) (ensures lognot a == UInt.lognot #n (a + pow2 n)) (* Shift operators *) (** If a is negative the result is undefined behaviour *) let shift_left (#n:pos) (a:int_t n{0 <= a}) (s:nat) : Tot (int_t n) = from_vec (shift_left_vec #n (to_vec #n a) s) (** If a is negative the result is implementation defined *) let shift_right (#n:pos) (a:int_t n{0 <= a}) (s:nat) : Tot (int_t n) = from_vec (shift_right_vec #n (to_vec #n a) s)
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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 shift_arithmetic_right (#n: pos) (a: int_t n) (s: nat) : Tot (int_t n)
[]
FStar.Int.shift_arithmetic_right
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int.int_t n -> s: Prims.nat -> FStar.Int.int_t n
{ "end_col": 58, "end_line": 401, "start_col": 2, "start_line": 401 }
Prims.Tot
val one (n: pos{1 < n}) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 one (n:pos{1 < n}) : Tot (int_t n) = 1
val one (n: pos{1 < n}) : Tot (int_t n) let one (n: pos{1 < n}) : Tot (int_t n) =
false
null
false
1
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "Prims.b2t", "Prims.op_LessThan", "FStar.Int.int_t" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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 one (n: pos{1 < n}) : Tot (int_t n)
[]
FStar.Int.one
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.pos{1 < n} -> FStar.Int.int_t n
{ "end_col": 42, "end_line": 74, "start_col": 41, "start_line": 74 }
Prims.Tot
val ones (n: pos) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 ones (n:pos) : Tot (int_t n) = -1
val ones (n: pos) : Tot (int_t n) let ones (n: pos) : Tot (int_t n) =
false
null
false
- 1
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "Prims.op_Minus", "FStar.Int.int_t" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1" let pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p let pow2_minus_one (#n:pos{1 < n}) (m:nat{m < n}) : Tot (int_t n) = pow2_le_compat (n - 1) m; pow2 m - 1 let one (n:pos{1 < n}) : Tot (int_t n) = 1 #pop-options
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ones (n: pos) : Tot (int_t n)
[]
FStar.Int.ones
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.pos -> FStar.Int.int_t n
{ "end_col": 37, "end_line": 78, "start_col": 35, "start_line": 78 }
Prims.Tot
val op_Slash (a: int) (b: int{b <> 0}) : Tot int
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b
val op_Slash (a: int) (b: int{b <> 0}) : Tot int let op_Slash (a: int) (b: int{b <> 0}) : Tot int =
false
null
false
if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.int", "Prims.b2t", "Prims.op_disEquality", "Prims.op_BarBar", "Prims.op_AmpAmp", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.op_Minus", "Prims.op_Division", "Prims.abs", "Prims.bool" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *)
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Slash (a: int) (b: int{b <> 0}) : Tot int
[]
FStar.Int.op_Slash
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Prims.int -> b: Prims.int{b <> 0} -> Prims.int
{ "end_col": 20, "end_line": 55, "start_col": 2, "start_line": 54 }
Prims.Tot
val pow2_n (#n: pos) (p: nat{p < n - 1}) : Tot (int_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 pow2_n (#n:pos) (p:nat{p < n-1}) : Tot (int_t n) = pow2_le_compat (n - 2) p; pow2 p
val pow2_n (#n: pos) (p: nat{p < n - 1}) : Tot (int_t n) let pow2_n (#n: pos) (p: nat{p < n - 1}) : Tot (int_t n) =
false
null
false
pow2_le_compat (n - 2) p; pow2 p
{ "checked_file": "FStar.Int.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.Int.fsti" }
[ "total" ]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Subtraction", "Prims.pow2", "Prims.unit", "FStar.Math.Lemmas.pow2_le_compat", "FStar.Int.int_t" ]
[]
(* 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.Int (* NOTE: anything that you fix/update here should be reflected in [FStar.UInt.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | _ -> True) [SMTPat (pow2 x)] /// Specs let max_int (n:pos) : Tot int = pow2 (n-1) - 1 let min_int (n:pos) : Tot int = - (pow2 (n-1)) let fits (x:int) (n:pos) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:pos) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type int_t (n:pos) = x:int{size x n} /// Multiplicative operator semantics, see C11 6.5.5 (* Truncation towards zero division *) let op_Slash (a:int) (b:int{b <> 0}) : Tot int = if (a >= 0 && b < 0) || (a < 0 && b >= 0) then - (abs a / abs b) else abs a / abs b (* Wrap-around modulo: wraps into [-p/2; p/2[ *) let op_At_Percent (v:int) (p:int{p>0/\ p%2=0}) : Tot int = let m = v % p in if m >= p/2 then m - p else m /// Constants let zero (n:pos) : Tot (int_t n) = 0 #push-options "--initial_fuel 1 --max_fuel 1"
false
false
FStar.Int.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "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 pow2_n (#n: pos) (p: nat{p < n - 1}) : Tot (int_t n)
[]
FStar.Int.pow2_n
{ "file_name": "ulib/FStar.Int.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: Prims.nat{p < n - 1} -> FStar.Int.int_t n
{ "end_col": 34, "end_line": 68, "start_col": 2, "start_line": 68 }