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 serialize_u32_le : serializer parse_u32_le
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 serialize_u32_le = serialize_synth _ synth_u32_le (serialize_bounded_integer_le 4) synth_u32_le_recip ()
val serialize_u32_le : serializer parse_u32_le let serialize_u32_le =
false
null
false
serialize_synth _ synth_u32_le (serialize_bounded_integer_le 4) synth_u32_le_recip ()
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.Combinators.serialize_synth", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "FStar.UInt32.t", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.synth_u32_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le", "LowParse.Spec.BoundedInt.synth_u32_le_recip" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = () let serialize_u16_le : serializer parse_u16_le = serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip () inline_for_extraction let synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) = x
false
true
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_u32_le : serializer parse_u32_le
[]
LowParse.Spec.BoundedInt.serialize_u32_le
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Spec.Base.serializer LowParse.Spec.BoundedInt.parse_u32_le
{ "end_col": 6, "end_line": 223, "start_col": 2, "start_line": 218 }
Prims.Tot
val parse_bounded_int32_le_fixed_size (min: nat) (max: nat { min <= max }) : Tot (parser parse_bounded_int32_fixed_size_kind (bounded_int32 min max))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 parse_bounded_int32_le_fixed_size min max = parse_filter parse_u32_le (in_bounds min max)
val parse_bounded_int32_le_fixed_size (min: nat) (max: nat { min <= max }) : Tot (parser parse_bounded_int32_fixed_size_kind (bounded_int32 min max)) let parse_bounded_int32_le_fixed_size min max =
false
null
false
parse_filter parse_u32_le (in_bounds min max)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.Int.parse_u32_kind", "FStar.UInt32.t", "LowParse.Spec.BoundedInt.parse_u32_le", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind", "LowParse.Spec.BoundedInt.bounded_int32" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = () let serialize_u16_le : serializer parse_u16_le = serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip () inline_for_extraction let synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) = x let serialize_u32_le = serialize_synth _ synth_u32_le (serialize_bounded_integer_le 4) synth_u32_le_recip () let parse_bounded_int32 min max = let sz = log256' max in (parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) let serialize_bounded_int32 min max = let sz = log256' max in serialize_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer sz) (in_bounds min max)) (fun x -> x) () let parse_bounded_int32_le min max = let sz = log256' max in (parse_bounded_integer_le sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) let serialize_bounded_int32_le min max = let sz = log256' max in serialize_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) () let parse_bounded_int32_le_fixed_size
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse_bounded_int32_le_fixed_size (min: nat) (max: nat { min <= max }) : Tot (parser parse_bounded_int32_fixed_size_kind (bounded_int32 min max))
[]
LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max} -> LowParse.Spec.Base.parser LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind (LowParse.Spec.BoundedInt.bounded_int32 min max)
{ "end_col": 47, "end_line": 257, "start_col": 2, "start_line": 257 }
FStar.Pervasives.Lemma
val bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
val bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) =
false
null
true
Classical.forall_intro_2 (bounded_integer_of_le_injective' i)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "lemma" ]
[ "LowParse.Spec.BoundedInt.integer_size", "FStar.Classical.forall_intro_2", "LowParse.Bytes.bytes", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.l_imp", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.bounded_integer_of_le", "FStar.Seq.Base.equal", "LowParse.Spec.BoundedInt.bounded_integer_of_le_injective'", "Prims.unit", "Prims.l_True", "Prims.squash", "LowParse.Spec.Combinators.make_total_constant_size_parser_precond", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i))
[]
LowParse.Spec.BoundedInt.bounded_integer_of_le_injective
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
i: LowParse.Spec.BoundedInt.integer_size -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Combinators.make_total_constant_size_parser_precond i (LowParse.Spec.BoundedInt.bounded_integer i) (LowParse.Spec.BoundedInt.bounded_integer_of_le i))
{ "end_col": 63, "end_line": 138, "start_col": 2, "start_line": 138 }
FStar.Pervasives.Lemma
val decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i)
val decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) =
false
null
true
Classical.forall_intro_2 (decode_bounded_integer_injective' i)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "lemma" ]
[ "LowParse.Spec.BoundedInt.integer_size", "FStar.Classical.forall_intro_2", "LowParse.Bytes.bytes", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.l_imp", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.decode_bounded_integer", "FStar.Seq.Base.equal", "LowParse.Spec.BoundedInt.decode_bounded_integer_injective'", "Prims.unit", "Prims.l_True", "Prims.squash", "LowParse.Spec.Combinators.make_total_constant_size_parser_precond", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i))
[]
LowParse.Spec.BoundedInt.decode_bounded_integer_injective
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
i: LowParse.Spec.BoundedInt.integer_size -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Combinators.make_total_constant_size_parser_precond i (LowParse.Spec.BoundedInt.bounded_integer i) (LowParse.Spec.BoundedInt.decode_bounded_integer i))
{ "end_col": 64, "end_line": 58, "start_col": 2, "start_line": 58 }
Prims.Tot
val serialize_u16_le : serializer parse_u16_le
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 serialize_u16_le : serializer parse_u16_le = serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip ()
val serialize_u16_le : serializer parse_u16_le let serialize_u16_le:serializer parse_u16_le =
false
null
false
serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip ()
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.Combinators.serialize_synth", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "FStar.UInt16.t", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.synth_u16_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le", "LowParse.Spec.BoundedInt.synth_u16_le_recip", "LowParse.Spec.Base.serializer", "LowParse.Spec.Int.parse_u16_kind", "LowParse.Spec.BoundedInt.parse_u16_le" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = ()
false
true
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_u16_le : serializer parse_u16_le
[]
LowParse.Spec.BoundedInt.serialize_u16_le
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Spec.Base.serializer LowParse.Spec.BoundedInt.parse_u16_le
{ "end_col": 6, "end_line": 209, "start_col": 2, "start_line": 204 }
Prims.Tot
val serialize_bounded_int32_le_fixed_size (min: nat) (max: nat { min <= max }) : Tot (serializer (parse_bounded_int32_le_fixed_size min max))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 serialize_bounded_int32_le_fixed_size min max = serialize_filter serialize_u32_le (in_bounds min max)
val serialize_bounded_int32_le_fixed_size (min: nat) (max: nat { min <= max }) : Tot (serializer (parse_bounded_int32_le_fixed_size min max)) let serialize_bounded_int32_le_fixed_size min max =
false
null
false
serialize_filter serialize_u32_le (in_bounds min max)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowParse.Spec.Combinators.serialize_filter", "LowParse.Spec.Int.parse_u32_kind", "FStar.UInt32.t", "LowParse.Spec.BoundedInt.parse_u32_le", "LowParse.Spec.BoundedInt.serialize_u32_le", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.Base.serializer", "LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = () let serialize_u16_le : serializer parse_u16_le = serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip () inline_for_extraction let synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) = x let serialize_u32_le = serialize_synth _ synth_u32_le (serialize_bounded_integer_le 4) synth_u32_le_recip () let parse_bounded_int32 min max = let sz = log256' max in (parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) let serialize_bounded_int32 min max = let sz = log256' max in serialize_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer sz) (in_bounds min max)) (fun x -> x) () let parse_bounded_int32_le min max = let sz = log256' max in (parse_bounded_integer_le sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) let serialize_bounded_int32_le min max = let sz = log256' max in serialize_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) () let parse_bounded_int32_le_fixed_size min max = parse_filter parse_u32_le (in_bounds min max) let serialize_bounded_int32_le_fixed_size
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_bounded_int32_le_fixed_size (min: nat) (max: nat { min <= max }) : Tot (serializer (parse_bounded_int32_le_fixed_size min max))
[]
LowParse.Spec.BoundedInt.serialize_bounded_int32_le_fixed_size
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max} -> LowParse.Spec.Base.serializer (LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size min max)
{ "end_col": 55, "end_line": 261, "start_col": 2, "start_line": 261 }
Prims.Tot
val synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4)
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) = x
val synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) let synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) =
false
null
false
x
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "LowParse.Spec.BoundedInt.bounded_integer" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = () let serialize_u16_le : serializer parse_u16_le = serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip () inline_for_extraction let synth_u32_le_recip (x: U32.t)
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4)
[]
LowParse.Spec.BoundedInt.synth_u32_le_recip
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
x: FStar.UInt32.t -> LowParse.Spec.BoundedInt.bounded_integer 4
{ "end_col": 3, "end_line": 215, "start_col": 2, "start_line": 215 }
Prims.Tot
val synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2)
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x
val synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) =
false
null
false
Cast.uint16_to_uint32 x
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt16.t", "FStar.Int.Cast.uint16_to_uint32", "LowParse.Spec.BoundedInt.bounded_integer" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t)
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2)
[]
LowParse.Spec.BoundedInt.synth_u16_le_recip
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
x: FStar.UInt16.t -> LowParse.Spec.BoundedInt.bounded_integer 2
{ "end_col": 25, "end_line": 199, "start_col": 2, "start_line": 199 }
Prims.Tot
val parse_bounded_int32 (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 parse_bounded_int32 min max = let sz = log256' max in (parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max))
val parse_bounded_int32 (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max)) let parse_bounded_int32 min max =
false
null
false
let sz = log256' max in ((parse_bounded_integer sz) `parse_filter` (in_bounds min max)) `parse_synth` (fun x -> (x <: bounded_int32 min max))
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = () let serialize_u16_le : serializer parse_u16_le = serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip () inline_for_extraction let synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) = x let serialize_u32_le = serialize_synth _ synth_u32_le (serialize_bounded_integer_le 4) synth_u32_le_recip () let parse_bounded_int32
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse_bounded_int32 (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max))
[]
LowParse.Spec.BoundedInt.parse_bounded_int32
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{0 < max /\ min <= max /\ max < 4294967296} -> LowParse.Spec.Base.parser (LowParse.Spec.BoundedInt.parse_bounded_int32_kind max) (LowParse.Spec.BoundedInt.bounded_int32 min max)
{ "end_col": 115, "end_line": 228, "start_col": 1, "start_line": 227 }
Prims.Tot
val parse_bounded_int32_le (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 parse_bounded_int32_le min max = let sz = log256' max in (parse_bounded_integer_le sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max))
val parse_bounded_int32_le (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max)) let parse_bounded_int32_le min max =
false
null
false
let sz = log256' max in ((parse_bounded_integer_le sz) `parse_filter` (in_bounds min max)) `parse_synth` (fun x -> (x <: bounded_int32 min max))
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = () let serialize_u16_le : serializer parse_u16_le = serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip () inline_for_extraction let synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) = x let serialize_u32_le = serialize_synth _ synth_u32_le (serialize_bounded_integer_le 4) synth_u32_le_recip () let parse_bounded_int32 min max = let sz = log256' max in (parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) let serialize_bounded_int32 min max = let sz = log256' max in serialize_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer sz) (in_bounds min max)) (fun x -> x) () let parse_bounded_int32_le
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse_bounded_int32_le (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (parser (parse_bounded_int32_kind max) (bounded_int32 min max))
[]
LowParse.Spec.BoundedInt.parse_bounded_int32_le
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{0 < max /\ min <= max /\ max < 4294967296} -> LowParse.Spec.Base.parser (LowParse.Spec.BoundedInt.parse_bounded_int32_kind max) (LowParse.Spec.BoundedInt.bounded_int32 min max)
{ "end_col": 118, "end_line": 243, "start_col": 1, "start_line": 242 }
Prims.Tot
val serialize_bounded_int32 (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (serializer (parse_bounded_int32 min max))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 serialize_bounded_int32 min max = let sz = log256' max in serialize_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer sz) (in_bounds min max)) (fun x -> x) ()
val serialize_bounded_int32 (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (serializer (parse_bounded_int32 min max)) let serialize_bounded_int32 min max =
false
null
false
let sz = log256' max in serialize_synth ((parse_bounded_integer sz) `parse_filter` (in_bounds min max)) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer sz) (in_bounds min max)) (fun x -> x) ()
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "LowParse.Spec.Combinators.serialize_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.Combinators.serialize_filter", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.serializer", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = () let serialize_u16_le : serializer parse_u16_le = serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip () inline_for_extraction let synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) = x let serialize_u32_le = serialize_synth _ synth_u32_le (serialize_bounded_integer_le 4) synth_u32_le_recip () let parse_bounded_int32 min max = let sz = log256' max in (parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) let serialize_bounded_int32
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_bounded_int32 (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (serializer (parse_bounded_int32 min max))
[]
LowParse.Spec.BoundedInt.serialize_bounded_int32
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{0 < max /\ min <= max /\ max < 4294967296} -> LowParse.Spec.Base.serializer (LowParse.Spec.BoundedInt.parse_bounded_int32 min max)
{ "end_col": 6, "end_line": 238, "start_col": 1, "start_line": 232 }
Prims.Tot
val serialize_bounded_int32_le (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (serializer (parse_bounded_int32_le min max))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 serialize_bounded_int32_le min max = let sz = log256' max in serialize_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) ()
val serialize_bounded_int32_le (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (serializer (parse_bounded_int32_le min max)) let serialize_bounded_int32_le min max =
false
null
false
let sz = log256' max in serialize_synth ((parse_bounded_integer_le sz) `parse_filter` (in_bounds min max)) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) ()
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "LowParse.Spec.Combinators.serialize_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.Combinators.serialize_filter", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le", "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.serializer", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32_le" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf #pop-options let serialize_bounded_integer_le sz = serialize_bounded_integer_le_correct sz; serialize_bounded_integer_le' sz inline_for_extraction let synth_u16_le_recip (x: U16.t) : Tot (bounded_integer 2) = Cast.uint16_to_uint32 x let synth_u16_le_inverse : squash (synth_inverse synth_u16_le synth_u16_le_recip) = () let serialize_u16_le : serializer parse_u16_le = serialize_synth _ synth_u16_le (serialize_bounded_integer_le 2) synth_u16_le_recip () inline_for_extraction let synth_u32_le_recip (x: U32.t) : Tot (bounded_integer 4) = x let serialize_u32_le = serialize_synth _ synth_u32_le (serialize_bounded_integer_le 4) synth_u32_le_recip () let parse_bounded_int32 min max = let sz = log256' max in (parse_bounded_integer sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) let serialize_bounded_int32 min max = let sz = log256' max in serialize_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (serialize_filter (serialize_bounded_integer sz) (in_bounds min max)) (fun x -> x) () let parse_bounded_int32_le min max = let sz = log256' max in (parse_bounded_integer_le sz `parse_filter` in_bounds min max) `parse_synth` (fun x -> (x <: bounded_int32 min max)) let serialize_bounded_int32_le
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_bounded_int32_le (min: nat) (max: nat { 0 < max /\ min <= max /\ max < 4294967296 }) : Tot (serializer (parse_bounded_int32_le min max))
[]
LowParse.Spec.BoundedInt.serialize_bounded_int32_le
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{0 < max /\ min <= max /\ max < 4294967296} -> LowParse.Spec.Base.serializer (LowParse.Spec.BoundedInt.parse_bounded_int32_le min max)
{ "end_col": 6, "end_line": 253, "start_col": 1, "start_line": 247 }
FStar.Pervasives.Lemma
val bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296)
val bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) =
false
null
true
assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "lemma" ]
[ "LowParse.Spec.BoundedInt.integer_size", "FStar.UInt32.t", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.pow2", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_iff", "LowParse.Spec.BoundedInt.bounded_integer_prop", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.Mul.op_Star", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i))
[]
LowParse.Spec.BoundedInt.bounded_integer_prop_equiv
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
i: LowParse.Spec.BoundedInt.integer_size -> u6: FStar.UInt32.t -> FStar.Pervasives.Lemma (ensures LowParse.Spec.BoundedInt.bounded_integer_prop i u6 <==> FStar.UInt32.v u6 < Prims.pow2 (8 * i) )
{ "end_col": 37, "end_line": 26, "start_col": 2, "start_line": 23 }
FStar.Pervasives.Lemma
val parse_bounded_integer_spec (i: integer_size) (input: bytes) : Lemma (let res = parse (parse_bounded_integer i) input in if Seq.length input < i then res == None else match res with | None -> False | Some (y, consumed) -> U32.v y == E.be_to_n (Seq.slice input 0 i) /\ consumed == i )
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input'
val parse_bounded_integer_spec (i: integer_size) (input: bytes) : Lemma (let res = parse (parse_bounded_integer i) input in if Seq.length input < i then res == None else match res with | None -> False | Some (y, consumed) -> U32.v y == E.be_to_n (Seq.slice input 0 i) /\ consumed == i ) let parse_bounded_integer_spec i input =
false
null
true
parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input'
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "lemma" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse_strong_prefix", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "Prims.unit", "FStar.Endianness.lemma_be_to_n_is_bounded", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "FStar.Seq.Base.slice", "FStar.Math.Lemmas.pow2_le_compat", "FStar.Mul.op_Star", "LowParse.Spec.Base.parser_kind_prop_equiv" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i)
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse_bounded_integer_spec (i: integer_size) (input: bytes) : Lemma (let res = parse (parse_bounded_integer i) input in if Seq.length input < i then res == None else match res with | None -> False | Some (y, consumed) -> U32.v y == E.be_to_n (Seq.slice input 0 i) /\ consumed == i )
[]
LowParse.Spec.BoundedInt.parse_bounded_integer_spec
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
i: LowParse.Spec.BoundedInt.integer_size -> input: LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (ensures (let res = LowParse.Spec.Base.parse (LowParse.Spec.BoundedInt.parse_bounded_integer i) input in (match FStar.Seq.Base.length input < i with | true -> res == FStar.Pervasives.Native.None | _ -> (match res with | FStar.Pervasives.Native.None #_ -> Prims.l_False | FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ y consumed) -> FStar.UInt32.v y == FStar.Endianness.be_to_n (FStar.Seq.Base.slice input 0 i) /\ consumed == i) <: Type0) <: Type0))
{ "end_col": 62, "end_line": 74, "start_col": 2, "start_line": 67 }
Prims.GTot
val decode_bounded_integer (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i)
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b)
val decode_bounded_integer (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i) let decode_bounded_integer (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i) =
false
null
false
E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "sometrivial" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Bytes.bytes", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "FStar.UInt32.uint_to_t", "FStar.Endianness.be_to_n", "Prims.unit", "FStar.Math.Lemmas.pow2_le_compat", "FStar.Mul.op_Star", "FStar.Endianness.lemma_be_to_n_is_bounded", "LowParse.Spec.BoundedInt.bounded_integer" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } )
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decode_bounded_integer (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i)
[]
LowParse.Spec.BoundedInt.decode_bounded_integer
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
i: LowParse.Spec.BoundedInt.integer_size -> b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == i} -> Prims.GTot (LowParse.Spec.BoundedInt.bounded_integer i)
{ "end_col": 29, "end_line": 36, "start_col": 2, "start_line": 34 }
FStar.Pervasives.Lemma
val decode_bounded_integer_injective' (i: integer_size) (b1: bytes{Seq.length b1 == i}) (b2: bytes{Seq.length b2 == i}) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else ()
val decode_bounded_integer_injective' (i: integer_size) (b1: bytes{Seq.length b1 == i}) (b2: bytes{Seq.length b2 == i}) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes{Seq.length b1 == i}) (b2: bytes{Seq.length b2 == i}) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) =
false
null
true
if decode_bounded_integer i b1 = decode_bounded_integer i b2 then (E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "lemma" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Bytes.bytes", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.op_Equality", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.decode_bounded_integer", "FStar.Endianness.be_to_n_inj", "Prims.unit", "Prims._assert", "FStar.Endianness.be_to_n", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "FStar.Endianness.lemma_be_to_n_is_bounded", "Prims.bool", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.Seq.Base.equal", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decode_bounded_integer_injective' (i: integer_size) (b1: bytes{Seq.length b1 == i}) (b2: bytes{Seq.length b2 == i}) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2)
[]
LowParse.Spec.BoundedInt.decode_bounded_integer_injective'
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
i: LowParse.Spec.BoundedInt.integer_size -> b1: LowParse.Bytes.bytes{FStar.Seq.Base.length b1 == i} -> b2: LowParse.Bytes.bytes{FStar.Seq.Base.length b2 == i} -> FStar.Pervasives.Lemma (ensures LowParse.Spec.BoundedInt.decode_bounded_integer i b1 == LowParse.Spec.BoundedInt.decode_bounded_integer i b2 ==> FStar.Seq.Base.equal b1 b2)
{ "end_col": 13, "end_line": 52, "start_col": 2, "start_line": 44 }
Prims.Tot
val serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz))
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) )
val serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) =
false
null
false
(fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x))
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.BoundedInt.bounded_integer", "FStar.Endianness.n_to_le", "FStar.UInt32.v", "LowParse.Bytes.bytes", "LowParse.Spec.Base.bare_serializer" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size)
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz))
[]
LowParse.Spec.BoundedInt.serialize_bounded_integer_le'
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> LowParse.Spec.Base.bare_serializer (LowParse.Spec.BoundedInt.bounded_integer sz)
{ "end_col": 3, "end_line": 168, "start_col": 2, "start_line": 166 }
Prims.Tot
val serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz))
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res )
val serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) =
false
null
false
(fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.BoundedInt.bounded_integer", "FStar.Endianness.bytes", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.UInt8.t", "FStar.UInt32.v", "FStar.Endianness.be_to_n", "FStar.Endianness.n_to_be", "LowParse.Bytes.bytes", "LowParse.Spec.Base.bare_serializer" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size)
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz))
[]
LowParse.Spec.BoundedInt.serialize_bounded_integer'
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> LowParse.Spec.Base.bare_serializer (LowParse.Spec.BoundedInt.bounded_integer sz)
{ "end_col": 3, "end_line": 82, "start_col": 2, "start_line": 79 }
FStar.Pervasives.Lemma
val bounded_integer_of_le_injective' (i: integer_size) (b1: bytes{Seq.length b1 == i}) (b2: bytes{Seq.length b2 == i}) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else ()
val bounded_integer_of_le_injective' (i: integer_size) (b1: bytes{Seq.length b1 == i}) (b2: bytes{Seq.length b2 == i}) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes{Seq.length b1 == i}) (b2: bytes{Seq.length b2 == i}) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) =
false
null
true
if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then (E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "lemma" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Bytes.bytes", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.op_Equality", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.bounded_integer_of_le", "FStar.Endianness.le_to_n_inj", "Prims.unit", "Prims._assert", "FStar.Endianness.le_to_n", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "FStar.Endianness.lemma_le_to_n_is_bounded", "Prims.bool", "Prims.l_True", "Prims.squash", "Prims.l_imp", "FStar.Seq.Base.equal", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bounded_integer_of_le_injective' (i: integer_size) (b1: bytes{Seq.length b1 == i}) (b2: bytes{Seq.length b2 == i}) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2)
[]
LowParse.Spec.BoundedInt.bounded_integer_of_le_injective'
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
i: LowParse.Spec.BoundedInt.integer_size -> b1: LowParse.Bytes.bytes{FStar.Seq.Base.length b1 == i} -> b2: LowParse.Bytes.bytes{FStar.Seq.Base.length b2 == i} -> FStar.Pervasives.Lemma (ensures LowParse.Spec.BoundedInt.bounded_integer_of_le i b1 == LowParse.Spec.BoundedInt.bounded_integer_of_le i b2 ==> FStar.Seq.Base.equal b1 b2)
{ "end_col": 13, "end_line": 130, "start_col": 2, "start_line": 122 }
Prims.GTot
val bounded_integer_of_le (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i)
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b)
val bounded_integer_of_le (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i) let bounded_integer_of_le (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i) =
false
null
false
E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b)
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "sometrivial" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Bytes.bytes", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "FStar.UInt32.uint_to_t", "FStar.Endianness.le_to_n", "Prims.unit", "FStar.Math.Lemmas.pow2_le_compat", "FStar.Mul.op_Star", "FStar.Endianness.lemma_le_to_n_is_bounded", "LowParse.Spec.BoundedInt.bounded_integer" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } )
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bounded_integer_of_le (i: integer_size) (b: bytes{Seq.length b == i}) : GTot (bounded_integer i)
[]
LowParse.Spec.BoundedInt.bounded_integer_of_le
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
i: LowParse.Spec.BoundedInt.integer_size -> b: LowParse.Bytes.bytes{FStar.Seq.Base.length b == i} -> Prims.GTot (LowParse.Spec.BoundedInt.bounded_integer i)
{ "end_col": 29, "end_line": 114, "start_col": 2, "start_line": 112 }
FStar.Pervasives.Lemma
val serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf
val serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) =
false
null
true
let prf (x: bounded_integer sz) : Lemma (let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "lemma" ]
[ "LowParse.Spec.BoundedInt.integer_size", "FStar.Classical.forall_intro", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.BoundedInt.serialize_bounded_integer'", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "LowParse.Spec.BoundedInt.parse_bounded_integer", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.Bytes.bytes", "LowParse.Spec.Base.serializer_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz))
[]
LowParse.Spec.BoundedInt.serialize_bounded_integer_correct
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Base.serializer_correct (LowParse.Spec.BoundedInt.parse_bounded_integer sz) (LowParse.Spec.BoundedInt.serialize_bounded_integer' sz))
{ "end_col": 28, "end_line": 98, "start_col": 1, "start_line": 88 }
FStar.Pervasives.Lemma
val serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
[ { "abbrev": false, "full_module": "LowParse.Spec.Combinators // for make_total_constant_size_parser_precond", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Math", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.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 serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf
val serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz)) =
false
null
true
let prf (x: bounded_integer sz) : Lemma (let res = serialize_bounded_integer_le' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer_le sz) res == Some (x, (sz <: nat))) = () in Classical.forall_intro prf
{ "checked_file": "LowParse.Spec.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Math.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Spec.BoundedInt.fst" }
[ "lemma" ]
[ "LowParse.Spec.BoundedInt.integer_size", "FStar.Classical.forall_intro", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le'", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.Bytes.bytes", "LowParse.Spec.Base.serializer_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind" ]
[]
module LowParse.Spec.BoundedInt open LowParse.Spec.Combinators // for make_total_constant_size_parser_precond module Seq = FStar.Seq module E = FStar.Endianness module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module M = LowParse.Math module Cast = FStar.Int.Cast (* bounded integers *) let integer_size_values i = () let bounded_integer_prop_equiv (i: integer_size) (u: U32.t) : Lemma (bounded_integer_prop i u <==> U32.v u < pow2 (8 * i)) = assert_norm (pow2 8 == 256); assert_norm (pow2 16 == 65536); assert_norm (pow2 24 == 16777216); assert_norm (pow2 32 == 4294967296) #push-options "--z3rlimit 16" let decode_bounded_integer (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_be_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.be_to_n b) let decode_bounded_integer_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (decode_bounded_integer i b1 == decode_bounded_integer i b2 ==> Seq.equal b1 b2) = if decode_bounded_integer i b1 = decode_bounded_integer i b2 then begin E.lemma_be_to_n_is_bounded b1; E.lemma_be_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.be_to_n b1)) == E.be_to_n b1); assert (U32.v (U32.uint_to_t (E.be_to_n b2)) == E.be_to_n b2); assert (E.be_to_n b1 == E.be_to_n b2); E.be_to_n_inj b1 b2 end else () let decode_bounded_integer_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (decode_bounded_integer i)) = Classical.forall_intro_2 (decode_bounded_integer_injective' i) let parse_bounded_integer (i: integer_size) : Tot (parser (parse_bounded_integer_kind i) (bounded_integer i)) = decode_bounded_integer_injective i; make_total_constant_size_parser i (bounded_integer i) (decode_bounded_integer i) let parse_bounded_integer_spec i input = parser_kind_prop_equiv (parse_bounded_integer_kind i) (parse_bounded_integer i); M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); match parse (parse_bounded_integer i) input with | None -> () | Some (y, consumed) -> let input' = Seq.slice input 0 i in E.lemma_be_to_n_is_bounded input'; parse_strong_prefix (parse_bounded_integer i) input input' let serialize_bounded_integer' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> let res = E.n_to_be sz (U32.v x) in res ) let serialize_bounded_integer_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer sz) (serialize_bounded_integer' sz)) = let prf (x: bounded_integer sz) : Lemma ( let res = serialize_bounded_integer' sz x in Seq.length res == (sz <: nat) /\ parse (parse_bounded_integer sz) res == Some (x, (sz <: nat)) ) = () in Classical.forall_intro prf let serialize_bounded_integer sz : Tot (serializer (parse_bounded_integer sz)) = serialize_bounded_integer_correct sz; serialize_bounded_integer' sz let serialize_bounded_integer_spec sz x = () let bounded_integer_of_le (i: integer_size) (b: bytes { Seq.length b == i } ) : GTot (bounded_integer i) = E.lemma_le_to_n_is_bounded b; M.pow2_le_compat 32 (8 `FStar.Mul.op_Star` i); U32.uint_to_t (E.le_to_n b) let bounded_integer_of_le_injective' (i: integer_size) (b1: bytes { Seq.length b1 == i } ) (b2: bytes { Seq.length b2 == i } ) : Lemma (bounded_integer_of_le i b1 == bounded_integer_of_le i b2 ==> Seq.equal b1 b2) = if bounded_integer_of_le i b1 = bounded_integer_of_le i b2 then begin E.lemma_le_to_n_is_bounded b1; E.lemma_le_to_n_is_bounded b2; assert (U32.v (U32.uint_to_t (E.le_to_n b1)) == E.le_to_n b1); assert (U32.v (U32.uint_to_t (E.le_to_n b2)) == E.le_to_n b2); assert (E.le_to_n b1 == E.le_to_n b2); E.le_to_n_inj b1 b2 end else () #pop-options let bounded_integer_of_le_injective (i: integer_size) : Lemma (make_total_constant_size_parser_precond i (bounded_integer i) (bounded_integer_of_le i)) = Classical.forall_intro_2 (bounded_integer_of_le_injective' i) let parse_bounded_integer_le i = bounded_integer_of_le_injective i; make_total_constant_size_parser i (bounded_integer i) (bounded_integer_of_le i) inline_for_extraction let synth_u16_le (x: bounded_integer 2) : Tot U16.t = Cast.uint32_to_uint16 x let synth_u16_le_injective : squash (synth_injective synth_u16_le) = () let parse_u16_le = parse_bounded_integer_le 2 `parse_synth` synth_u16_le inline_for_extraction let synth_u32_le (x: bounded_integer 4) : Tot U32.t = x let parse_u32_le = parse_bounded_integer_le 4 `parse_synth` synth_u32_le let serialize_bounded_integer_le' (sz: integer_size) : Tot (bare_serializer (bounded_integer sz)) = (fun (x: bounded_integer sz) -> E.n_to_le sz (U32.v x) ) #push-options "--z3rlimit 16" let serialize_bounded_integer_le_correct (sz: integer_size) : Lemma
false
false
LowParse.Spec.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize_bounded_integer_le_correct (sz: integer_size) : Lemma (serializer_correct (parse_bounded_integer_le sz) (serialize_bounded_integer_le' sz))
[]
LowParse.Spec.BoundedInt.serialize_bounded_integer_le_correct
{ "file_name": "src/lowparse/LowParse.Spec.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Base.serializer_correct (LowParse.Spec.BoundedInt.parse_bounded_integer_le sz) (LowParse.Spec.BoundedInt.serialize_bounded_integer_le' sz))
{ "end_col": 28, "end_line": 186, "start_col": 1, "start_line": 176 }
Prims.Tot
val wrap_slice (#a: Type0) (s: Seq.seq a) (i: int) : Seq.seq a
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0)
val wrap_slice (#a: Type0) (s: Seq.seq a) (i: int) : Seq.seq a let wrap_slice (#a: Type0) (s: Seq.seq a) (i: int) : Seq.seq a =
false
null
false
Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0)
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "total" ]
[ "FStar.Seq.Base.seq", "FStar.Integers.int", "FStar.Seq.Base.slice", "Prims.op_AmpAmp", "FStar.Integers.op_Less_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Seq.Base.length", "Prims.bool", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers
false
false
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val wrap_slice (#a: Type0) (s: Seq.seq a) (i: int) : Seq.seq a
[]
Vale.Wrapper.X64.GCMencryptOpt.wrap_slice
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq a -> i: FStar.Integers.int -> FStar.Seq.Base.seq a
{ "end_col": 62, "end_line": 21, "start_col": 2, "start_line": 21 }
FStar.Pervasives.Lemma
val length_div (b: uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1)
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let length_div (b:uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) = DV.length_eq (get_downview b)
val length_div (b: uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) let length_div (b: uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) =
false
null
true
DV.length_eq (get_downview b)
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "lemma" ]
[ "Vale.Wrapper.X64.GCMencryptOpt.uint8_p", "LowStar.BufferView.Down.length_eq", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Arch.HeapTypes_s.TUInt8", "LowStar.Buffer.trivial_preorder", "Prims.unit", "Prims.b2t", "Prims.op_Equality", "Prims.int", "LowStar.Monotonic.Buffer.length", "Prims.squash", "FStar.Integers.op_Slash", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.BufferView.Down.length", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) #reset-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" let math_aux (n:nat) : Lemma (n * 1 == n) = () let length_div (b:uint8_p) : Lemma (requires B.length b = 16)
false
false
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val length_div (b: uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1)
[]
Vale.Wrapper.X64.GCMencryptOpt.length_div
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.length b = 16) (ensures LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview b) / 16 = 1)
{ "end_col": 33, "end_line": 30, "start_col": 4, "start_line": 30 }
FStar.Pervasives.Lemma
val math_cast_aux (n: UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n)
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let math_cast_aux (n:UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n) = FStar.Math.Lemmas.small_mod (UInt64.v n) (pow2 32)
val math_cast_aux (n: UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n) let math_cast_aux (n: UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n) =
false
null
true
FStar.Math.Lemmas.small_mod (UInt64.v n) (pow2 32)
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "lemma" ]
[ "FStar.UInt64.t", "FStar.Math.Lemmas.small_mod", "FStar.UInt64.v", "Prims.pow2", "Prims.unit", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "Prims.squash", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "FStar.UInt64.n", "FStar.UInt32.v", "FStar.Int.Cast.uint64_to_uint32", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) #reset-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" let math_aux (n:nat) : Lemma (n * 1 == n) = () let length_div (b:uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) = DV.length_eq (get_downview b) inline_for_extraction val gcm128_encrypt_opt': key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> auth_b:uint8_p -> auth_bytes:uint64 -> auth_num:uint64 -> keys_b:uint8_p -> iv_b:uint8_p -> hkeys_b:uint8_p -> abytes_b:uint8_p -> in128x6_b:uint8_p -> out128x6_b:uint8_p -> len128x6:uint64 -> in128_b:uint8_p -> out128_b:uint8_p -> len128_num:uint64 -> inout_b:uint8_p -> plain_num:uint64 -> scratch_b:uint8_p -> tag_b:uint8_p -> Stack unit (requires fun h0 -> B.disjoint tag_b keys_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b abytes_b /\ B.disjoint tag_b iv_b /\ B.disjoint tag_b in128x6_b /\ B.disjoint tag_b out128x6_b /\ B.disjoint tag_b in128_b /\ B.disjoint tag_b out128_b /\ B.disjoint tag_b inout_b /\ B.disjoint tag_b scratch_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b auth_b /\ B.disjoint iv_b abytes_b /\ B.disjoint iv_b in128x6_b /\ B.disjoint iv_b out128x6_b /\ B.disjoint iv_b in128_b /\ B.disjoint iv_b out128_b /\ B.disjoint iv_b inout_b /\ B.disjoint iv_b scratch_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint scratch_b in128x6_b /\ B.disjoint scratch_b out128x6_b /\ B.disjoint scratch_b in128_b /\ B.disjoint scratch_b out128_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b abytes_b /\ B.disjoint inout_b in128x6_b /\ B.disjoint inout_b out128x6_b /\ B.disjoint inout_b in128_b /\ B.disjoint inout_b out128_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint out128x6_b keys_b /\ B.disjoint out128x6_b auth_b /\ B.disjoint out128x6_b abytes_b /\ B.disjoint out128x6_b hkeys_b /\ B.disjoint out128x6_b in128_b /\ B.disjoint out128x6_b inout_b /\ B.disjoint in128x6_b keys_b /\ B.disjoint in128x6_b auth_b /\ B.disjoint in128x6_b abytes_b /\ B.disjoint in128x6_b hkeys_b /\ B.disjoint in128x6_b in128_b /\ B.disjoint in128x6_b inout_b /\ B.disjoint out128_b keys_b /\ B.disjoint out128_b auth_b /\ B.disjoint out128_b abytes_b /\ B.disjoint out128_b hkeys_b /\ B.disjoint out128_b in128x6_b /\ B.disjoint out128_b out128x6_b /\ B.disjoint out128_b inout_b /\ B.disjoint in128_b keys_b /\ B.disjoint in128_b auth_b /\ B.disjoint in128_b abytes_b /\ B.disjoint in128_b hkeys_b /\ B.disjoint in128_b in128x6_b /\ B.disjoint in128_b out128x6_b /\ B.disjoint in128_b inout_b /\ B.disjoint keys_b abytes_b /\ B.disjoint hkeys_b auth_b /\ B.disjoint hkeys_b abytes_b /\ B.disjoint auth_b abytes_b /\ B.disjoint keys_b auth_b /\ disjoint_or_eq in128x6_b out128x6_b /\ disjoint_or_eq in128_b out128_b /\ disjoint_or_eq keys_b hkeys_b /\ B.live h0 auth_b /\ B.live h0 abytes_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 in128x6_b /\ B.live h0 out128x6_b /\ B.live h0 in128_b /\ B.live h0 out128_b /\ B.live h0 inout_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.length auth_b = 16 * UInt64.v auth_num /\ B.length abytes_b == 16 /\ B.length iv_b = 16 /\ B.length in128x6_b == 16 * UInt64.v len128x6 /\ B.length out128x6_b == B.length in128x6_b /\ B.length in128_b == 16 * UInt64.v len128_num /\ B.length out128_b == B.length in128_b /\ B.length inout_b == 16 /\ B.length scratch_b == 144 /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ UInt64.v plain_num < pow2_32 /\ UInt64.v auth_bytes < pow2_32 /\ UInt64.v len128x6 % 6 == 0 /\ (UInt64.v len128x6 > 0 ==> UInt64.v len128x6 >= 18) /\ 12 + UInt64.v len128x6 + 6 < pow2_32 /\ UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) <= UInt64.v plain_num /\ UInt64.v plain_num < UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) + 128/8 /\ UInt64.v auth_num * (128/8) <= UInt64.v auth_bytes /\ UInt64.v auth_bytes < UInt64.v auth_num * (128/8) + 128/8 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) /\ (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)))) /\ (length_div iv_b; (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out128x6_b) (B.loc_union (B.loc_buffer out128_b) (B.loc_buffer inout_b)))))) h0 h1 /\ ((UInt64.v plain_num) < pow2_32 /\ (UInt64.v auth_bytes) < pow2_32 /\ ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_num) in let cipher_out = Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_num) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_num); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_bytes) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ is_aes_key AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in cipher == cipher_bytes /\ (length_div tag_b; le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h1 tag_b 0) == tag )))) ) #push-options "--z3cliopt smt.arith.nl=true --retry 3 --z3rlimit 800 --ext compat:normalizer_memo_ignore_cfg" #restart-solver inline_for_extraction let gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b = let h0 = get() in B.disjoint_neq iv_b auth_b; B.disjoint_neq iv_b keys_b; B.disjoint_neq iv_b hkeys_b; B.disjoint_neq iv_b abytes_b; B.disjoint_neq iv_b in128x6_b; B.disjoint_neq iv_b out128x6_b; B.disjoint_neq iv_b in128_b; B.disjoint_neq iv_b out128_b; B.disjoint_neq iv_b inout_b; B.disjoint_neq iv_b scratch_b; B.disjoint_neq iv_b tag_b; DV.length_eq (get_downview auth_b); DV.length_eq (get_downview keys_b); DV.length_eq (get_downview iv_b); DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview abytes_b); DV.length_eq (get_downview in128x6_b); DV.length_eq (get_downview out128x6_b); DV.length_eq (get_downview in128_b); DV.length_eq (get_downview out128_b); DV.length_eq (get_downview inout_b); DV.length_eq (get_downview scratch_b); DV.length_eq (get_downview tag_b); math_aux (B.length auth_b); math_aux (B.length keys_b); math_aux (B.length iv_b); math_aux (B.length hkeys_b); math_aux (B.length in128x6_b); math_aux (B.length scratch_b); math_aux (B.length out128_b); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v auth_num) 16; assert_norm (176 % 16 = 0); assert_norm (16 % 16 = 0); assert_norm (144 % 16 = 0); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128x6) 16; FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128_num) 16; calc (<=) { 256 * ((16 * UInt64.v len128_num) / 16); (==) { FStar.Math.Lemmas.cancel_mul_div (UInt64.v len128_num) 16 } 256 * (UInt64.v len128_num); ( <= ) { assert_norm (256 <= 4096); FStar.Math.Lemmas.lemma_mult_le_right (UInt64.v len128_num) 256 4096 } 4096 * (UInt64.v len128_num); }; assert (DV.length (get_downview tag_b) % 16 = 0); assert (DV.length (get_downview scratch_b) % 16 = 0); assert (DV.length (get_downview out128_b) % 16 = 0); as_vale_buffer_len #TUInt8 #TUInt128 auth_b; as_vale_buffer_len #TUInt8 #TUInt128 keys_b; as_vale_buffer_len #TUInt8 #TUInt128 iv_b; as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b; as_vale_buffer_len #TUInt8 #TUInt128 abytes_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128_b; as_vale_buffer_len #TUInt8 #TUInt128 inout_b; as_vale_buffer_len #TUInt8 #TUInt128 scratch_b; as_vale_buffer_len #TUInt8 #TUInt128 tag_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 auth_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 inout_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 keys_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b; let (x, _) = gcm128_encrypt_opt key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b () in let h1 = get() in () #pop-options inline_for_extraction val gcm128_encrypt_opt_alloca: key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> plain_b:uint8_p -> plain_len:uint64 -> auth_b:uint8_p -> auth_len:uint64 -> iv_b:uint8_p -> out_b:uint8_p -> tag_b:uint8_p -> keys_b:uint8_p -> hkeys_b:uint8_p -> scratch_b:uint8_p -> inout_b : uint8_p -> abytes_b : uint8_p -> Stack unit (requires fun h0 -> B.disjoint scratch_b tag_b /\ B.disjoint scratch_b out_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint scratch_b plain_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b iv_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint inout_b tag_b /\ B.disjoint inout_b out_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint inout_b plain_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b iv_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b abytes_b /\ B.disjoint abytes_b tag_b /\ B.disjoint abytes_b out_b /\ B.disjoint abytes_b hkeys_b /\ B.disjoint abytes_b plain_b /\ B.disjoint abytes_b auth_b /\ B.disjoint abytes_b iv_b /\ B.disjoint abytes_b keys_b /\ B.disjoint tag_b out_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint tag_b plain_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b iv_b /\ disjoint_or_eq tag_b keys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b out_b /\ B.disjoint iv_b plain_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint iv_b auth_b /\ B.disjoint out_b keys_b /\ B.disjoint out_b hkeys_b /\ B.disjoint out_b auth_b /\ disjoint_or_eq out_b plain_b /\ B.disjoint plain_b keys_b /\ B.disjoint plain_b hkeys_b /\ B.disjoint plain_b auth_b /\ disjoint_or_eq keys_b hkeys_b /\ B.disjoint keys_b auth_b /\ B.disjoint hkeys_b auth_b /\ B.live h0 auth_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 out_b /\ B.live h0 plain_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.live h0 inout_b /\ B.live h0 abytes_b /\ B.length auth_b = (UInt64.v auth_len / 16) * 16 /\ B.length iv_b = 16 /\ B.length plain_b = (UInt64.v plain_len / 16) * 16 /\ B.length out_b = B.length plain_b /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ B.length scratch_b = 144 /\ B.length inout_b = 16 /\ B.length abytes_b = 16 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (Seq.equal (B.as_seq h0 keys_b) (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key))))) /\ hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0))) /\ (le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out_b) (B.loc_buffer inout_b))))) h0 h1 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ (let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in Seq.length plain_bytes < pow2_32 /\ Seq.length auth_bytes < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h1 tag_b)) tag ) )) let lemma_same_seq_dv (h:HS.mem) (b:uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) = let db = get_downview b in DV.length_eq db; let aux (i:nat{i < B.length b}) : Lemma (Seq.index (B.as_seq h b) i == Seq.index (DV.as_seq h db) i) = DV.as_seq_sel h db i; DV.get_sel h db i; Vale.Interop.Views.put8_reveal () in Classical.forall_intro aux let lemma_uv_split (h:HS.mem) (b:uint8_p) (n:UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures ( let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs) ) = let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in calc (==) { Seq.length split_bs; (==) { } Seq.length (UV.as_seq h b1_u) + Seq.length (UV.as_seq h b2_u); (==) { UV.length_eq b1_u; UV.length_eq b2_u } DV.length b1_d / 16 + DV.length b2_d / 16; (==) { DV.length_eq b1_d; DV.length_eq b2_d; math_aux (B.length b1); math_aux (B.length b2) } B.length b1 / 16 + B.length b2 / 16; (==) { } B.length b / 16; (==) { DV.length_eq b_d; UV.length_eq b_u; math_aux (B.length b) } Seq.length bs; }; assert (Seq.length bs == Seq.length split_bs); let aux (i:nat{ i < Seq.length bs}) : Lemma (Seq.index bs i = Seq.index split_bs i) = UV.length_eq b_u; lemma_same_seq_dv h b; calc (==) { Seq.index bs i; (==) { UV.as_seq_sel h b_u i } UV.sel h b_u i; (==) { UV.get_sel h b_u i } Vale.Interop.Views.get128 (Seq.slice (DV.as_seq h b_d) (i * 16) (i * 16 + 16)); (==) { lemma_same_seq_dv h b } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b) (i * 16) (i * 16 + 16)); (==) { assert (Seq.equal (B.as_seq h b) (Seq.append (B.as_seq h b1) (B.as_seq h b2))) } Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); }; if i < Seq.length (UV.as_seq h b1_u) then ( lemma_same_seq_dv h b1; UV.length_eq b1_u; calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b1) (i * 16) (i * 16 + 16)); (==) { UV.get_sel h b1_u i } UV.sel h b1_u i; (==) { UV.as_seq_sel h b1_u i } Seq.index (UV.as_seq h b1_u) i; (==) { } Seq.index split_bs i; } ) else ( lemma_same_seq_dv h b2; UV.length_eq b2_u; let j = i - UV.length b1_u in calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b2) (j * 16) (j * 16 + 16)); (==) { UV.get_sel h b2_u j } UV.sel h b2_u j; (==) { UV.as_seq_sel h b2_u j } Seq.index (UV.as_seq h b2_u) j; (==) { } Seq.index split_bs i; } ) in Classical.forall_intro aux let math_cast_aux (n:UInt64.t) : Lemma (requires UInt64.v n < pow2 32)
false
false
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val math_cast_aux (n: UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n)
[]
Vale.Wrapper.X64.GCMencryptOpt.math_cast_aux
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: FStar.UInt64.t -> FStar.Pervasives.Lemma (requires FStar.UInt64.v n < Prims.pow2 32) (ensures FStar.UInt32.v (FStar.Int.Cast.uint64_to_uint32 n) = FStar.UInt64.v n)
{ "end_col": 54, "end_line": 522, "start_col": 4, "start_line": 522 }
FStar.Pervasives.Lemma
val length_aux6 (b: uint8_p) : Lemma (B.length b = DV.length (get_downview b))
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let length_aux6 (b:uint8_p) : Lemma (B.length b = DV.length (get_downview b)) = DV.length_eq (get_downview b)
val length_aux6 (b: uint8_p) : Lemma (B.length b = DV.length (get_downview b)) let length_aux6 (b: uint8_p) : Lemma (B.length b = DV.length (get_downview b)) =
false
null
true
DV.length_eq (get_downview b)
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "lemma" ]
[ "Vale.Wrapper.X64.GCMencryptOpt.uint8_p", "LowStar.BufferView.Down.length_eq", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Arch.HeapTypes_s.TUInt8", "LowStar.Buffer.trivial_preorder", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "LowStar.Monotonic.Buffer.length", "LowStar.BufferView.Down.length", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) #reset-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" let math_aux (n:nat) : Lemma (n * 1 == n) = () let length_div (b:uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) = DV.length_eq (get_downview b) inline_for_extraction val gcm128_encrypt_opt': key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> auth_b:uint8_p -> auth_bytes:uint64 -> auth_num:uint64 -> keys_b:uint8_p -> iv_b:uint8_p -> hkeys_b:uint8_p -> abytes_b:uint8_p -> in128x6_b:uint8_p -> out128x6_b:uint8_p -> len128x6:uint64 -> in128_b:uint8_p -> out128_b:uint8_p -> len128_num:uint64 -> inout_b:uint8_p -> plain_num:uint64 -> scratch_b:uint8_p -> tag_b:uint8_p -> Stack unit (requires fun h0 -> B.disjoint tag_b keys_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b abytes_b /\ B.disjoint tag_b iv_b /\ B.disjoint tag_b in128x6_b /\ B.disjoint tag_b out128x6_b /\ B.disjoint tag_b in128_b /\ B.disjoint tag_b out128_b /\ B.disjoint tag_b inout_b /\ B.disjoint tag_b scratch_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b auth_b /\ B.disjoint iv_b abytes_b /\ B.disjoint iv_b in128x6_b /\ B.disjoint iv_b out128x6_b /\ B.disjoint iv_b in128_b /\ B.disjoint iv_b out128_b /\ B.disjoint iv_b inout_b /\ B.disjoint iv_b scratch_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint scratch_b in128x6_b /\ B.disjoint scratch_b out128x6_b /\ B.disjoint scratch_b in128_b /\ B.disjoint scratch_b out128_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b abytes_b /\ B.disjoint inout_b in128x6_b /\ B.disjoint inout_b out128x6_b /\ B.disjoint inout_b in128_b /\ B.disjoint inout_b out128_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint out128x6_b keys_b /\ B.disjoint out128x6_b auth_b /\ B.disjoint out128x6_b abytes_b /\ B.disjoint out128x6_b hkeys_b /\ B.disjoint out128x6_b in128_b /\ B.disjoint out128x6_b inout_b /\ B.disjoint in128x6_b keys_b /\ B.disjoint in128x6_b auth_b /\ B.disjoint in128x6_b abytes_b /\ B.disjoint in128x6_b hkeys_b /\ B.disjoint in128x6_b in128_b /\ B.disjoint in128x6_b inout_b /\ B.disjoint out128_b keys_b /\ B.disjoint out128_b auth_b /\ B.disjoint out128_b abytes_b /\ B.disjoint out128_b hkeys_b /\ B.disjoint out128_b in128x6_b /\ B.disjoint out128_b out128x6_b /\ B.disjoint out128_b inout_b /\ B.disjoint in128_b keys_b /\ B.disjoint in128_b auth_b /\ B.disjoint in128_b abytes_b /\ B.disjoint in128_b hkeys_b /\ B.disjoint in128_b in128x6_b /\ B.disjoint in128_b out128x6_b /\ B.disjoint in128_b inout_b /\ B.disjoint keys_b abytes_b /\ B.disjoint hkeys_b auth_b /\ B.disjoint hkeys_b abytes_b /\ B.disjoint auth_b abytes_b /\ B.disjoint keys_b auth_b /\ disjoint_or_eq in128x6_b out128x6_b /\ disjoint_or_eq in128_b out128_b /\ disjoint_or_eq keys_b hkeys_b /\ B.live h0 auth_b /\ B.live h0 abytes_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 in128x6_b /\ B.live h0 out128x6_b /\ B.live h0 in128_b /\ B.live h0 out128_b /\ B.live h0 inout_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.length auth_b = 16 * UInt64.v auth_num /\ B.length abytes_b == 16 /\ B.length iv_b = 16 /\ B.length in128x6_b == 16 * UInt64.v len128x6 /\ B.length out128x6_b == B.length in128x6_b /\ B.length in128_b == 16 * UInt64.v len128_num /\ B.length out128_b == B.length in128_b /\ B.length inout_b == 16 /\ B.length scratch_b == 144 /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ UInt64.v plain_num < pow2_32 /\ UInt64.v auth_bytes < pow2_32 /\ UInt64.v len128x6 % 6 == 0 /\ (UInt64.v len128x6 > 0 ==> UInt64.v len128x6 >= 18) /\ 12 + UInt64.v len128x6 + 6 < pow2_32 /\ UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) <= UInt64.v plain_num /\ UInt64.v plain_num < UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) + 128/8 /\ UInt64.v auth_num * (128/8) <= UInt64.v auth_bytes /\ UInt64.v auth_bytes < UInt64.v auth_num * (128/8) + 128/8 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) /\ (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)))) /\ (length_div iv_b; (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out128x6_b) (B.loc_union (B.loc_buffer out128_b) (B.loc_buffer inout_b)))))) h0 h1 /\ ((UInt64.v plain_num) < pow2_32 /\ (UInt64.v auth_bytes) < pow2_32 /\ ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_num) in let cipher_out = Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_num) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_num); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_bytes) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ is_aes_key AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in cipher == cipher_bytes /\ (length_div tag_b; le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h1 tag_b 0) == tag )))) ) #push-options "--z3cliopt smt.arith.nl=true --retry 3 --z3rlimit 800 --ext compat:normalizer_memo_ignore_cfg" #restart-solver inline_for_extraction let gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b = let h0 = get() in B.disjoint_neq iv_b auth_b; B.disjoint_neq iv_b keys_b; B.disjoint_neq iv_b hkeys_b; B.disjoint_neq iv_b abytes_b; B.disjoint_neq iv_b in128x6_b; B.disjoint_neq iv_b out128x6_b; B.disjoint_neq iv_b in128_b; B.disjoint_neq iv_b out128_b; B.disjoint_neq iv_b inout_b; B.disjoint_neq iv_b scratch_b; B.disjoint_neq iv_b tag_b; DV.length_eq (get_downview auth_b); DV.length_eq (get_downview keys_b); DV.length_eq (get_downview iv_b); DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview abytes_b); DV.length_eq (get_downview in128x6_b); DV.length_eq (get_downview out128x6_b); DV.length_eq (get_downview in128_b); DV.length_eq (get_downview out128_b); DV.length_eq (get_downview inout_b); DV.length_eq (get_downview scratch_b); DV.length_eq (get_downview tag_b); math_aux (B.length auth_b); math_aux (B.length keys_b); math_aux (B.length iv_b); math_aux (B.length hkeys_b); math_aux (B.length in128x6_b); math_aux (B.length scratch_b); math_aux (B.length out128_b); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v auth_num) 16; assert_norm (176 % 16 = 0); assert_norm (16 % 16 = 0); assert_norm (144 % 16 = 0); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128x6) 16; FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128_num) 16; calc (<=) { 256 * ((16 * UInt64.v len128_num) / 16); (==) { FStar.Math.Lemmas.cancel_mul_div (UInt64.v len128_num) 16 } 256 * (UInt64.v len128_num); ( <= ) { assert_norm (256 <= 4096); FStar.Math.Lemmas.lemma_mult_le_right (UInt64.v len128_num) 256 4096 } 4096 * (UInt64.v len128_num); }; assert (DV.length (get_downview tag_b) % 16 = 0); assert (DV.length (get_downview scratch_b) % 16 = 0); assert (DV.length (get_downview out128_b) % 16 = 0); as_vale_buffer_len #TUInt8 #TUInt128 auth_b; as_vale_buffer_len #TUInt8 #TUInt128 keys_b; as_vale_buffer_len #TUInt8 #TUInt128 iv_b; as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b; as_vale_buffer_len #TUInt8 #TUInt128 abytes_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128_b; as_vale_buffer_len #TUInt8 #TUInt128 inout_b; as_vale_buffer_len #TUInt8 #TUInt128 scratch_b; as_vale_buffer_len #TUInt8 #TUInt128 tag_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 auth_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 inout_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 keys_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b; let (x, _) = gcm128_encrypt_opt key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b () in let h1 = get() in () #pop-options inline_for_extraction val gcm128_encrypt_opt_alloca: key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> plain_b:uint8_p -> plain_len:uint64 -> auth_b:uint8_p -> auth_len:uint64 -> iv_b:uint8_p -> out_b:uint8_p -> tag_b:uint8_p -> keys_b:uint8_p -> hkeys_b:uint8_p -> scratch_b:uint8_p -> inout_b : uint8_p -> abytes_b : uint8_p -> Stack unit (requires fun h0 -> B.disjoint scratch_b tag_b /\ B.disjoint scratch_b out_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint scratch_b plain_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b iv_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint inout_b tag_b /\ B.disjoint inout_b out_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint inout_b plain_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b iv_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b abytes_b /\ B.disjoint abytes_b tag_b /\ B.disjoint abytes_b out_b /\ B.disjoint abytes_b hkeys_b /\ B.disjoint abytes_b plain_b /\ B.disjoint abytes_b auth_b /\ B.disjoint abytes_b iv_b /\ B.disjoint abytes_b keys_b /\ B.disjoint tag_b out_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint tag_b plain_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b iv_b /\ disjoint_or_eq tag_b keys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b out_b /\ B.disjoint iv_b plain_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint iv_b auth_b /\ B.disjoint out_b keys_b /\ B.disjoint out_b hkeys_b /\ B.disjoint out_b auth_b /\ disjoint_or_eq out_b plain_b /\ B.disjoint plain_b keys_b /\ B.disjoint plain_b hkeys_b /\ B.disjoint plain_b auth_b /\ disjoint_or_eq keys_b hkeys_b /\ B.disjoint keys_b auth_b /\ B.disjoint hkeys_b auth_b /\ B.live h0 auth_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 out_b /\ B.live h0 plain_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.live h0 inout_b /\ B.live h0 abytes_b /\ B.length auth_b = (UInt64.v auth_len / 16) * 16 /\ B.length iv_b = 16 /\ B.length plain_b = (UInt64.v plain_len / 16) * 16 /\ B.length out_b = B.length plain_b /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ B.length scratch_b = 144 /\ B.length inout_b = 16 /\ B.length abytes_b = 16 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (Seq.equal (B.as_seq h0 keys_b) (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key))))) /\ hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0))) /\ (le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out_b) (B.loc_buffer inout_b))))) h0 h1 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ (let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in Seq.length plain_bytes < pow2_32 /\ Seq.length auth_bytes < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h1 tag_b)) tag ) )) let lemma_same_seq_dv (h:HS.mem) (b:uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) = let db = get_downview b in DV.length_eq db; let aux (i:nat{i < B.length b}) : Lemma (Seq.index (B.as_seq h b) i == Seq.index (DV.as_seq h db) i) = DV.as_seq_sel h db i; DV.get_sel h db i; Vale.Interop.Views.put8_reveal () in Classical.forall_intro aux let lemma_uv_split (h:HS.mem) (b:uint8_p) (n:UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures ( let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs) ) = let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in calc (==) { Seq.length split_bs; (==) { } Seq.length (UV.as_seq h b1_u) + Seq.length (UV.as_seq h b2_u); (==) { UV.length_eq b1_u; UV.length_eq b2_u } DV.length b1_d / 16 + DV.length b2_d / 16; (==) { DV.length_eq b1_d; DV.length_eq b2_d; math_aux (B.length b1); math_aux (B.length b2) } B.length b1 / 16 + B.length b2 / 16; (==) { } B.length b / 16; (==) { DV.length_eq b_d; UV.length_eq b_u; math_aux (B.length b) } Seq.length bs; }; assert (Seq.length bs == Seq.length split_bs); let aux (i:nat{ i < Seq.length bs}) : Lemma (Seq.index bs i = Seq.index split_bs i) = UV.length_eq b_u; lemma_same_seq_dv h b; calc (==) { Seq.index bs i; (==) { UV.as_seq_sel h b_u i } UV.sel h b_u i; (==) { UV.get_sel h b_u i } Vale.Interop.Views.get128 (Seq.slice (DV.as_seq h b_d) (i * 16) (i * 16 + 16)); (==) { lemma_same_seq_dv h b } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b) (i * 16) (i * 16 + 16)); (==) { assert (Seq.equal (B.as_seq h b) (Seq.append (B.as_seq h b1) (B.as_seq h b2))) } Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); }; if i < Seq.length (UV.as_seq h b1_u) then ( lemma_same_seq_dv h b1; UV.length_eq b1_u; calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b1) (i * 16) (i * 16 + 16)); (==) { UV.get_sel h b1_u i } UV.sel h b1_u i; (==) { UV.as_seq_sel h b1_u i } Seq.index (UV.as_seq h b1_u) i; (==) { } Seq.index split_bs i; } ) else ( lemma_same_seq_dv h b2; UV.length_eq b2_u; let j = i - UV.length b1_u in calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b2) (j * 16) (j * 16 + 16)); (==) { UV.get_sel h b2_u j } UV.sel h b2_u j; (==) { UV.as_seq_sel h b2_u j } Seq.index (UV.as_seq h b2_u) j; (==) { } Seq.index split_bs i; } ) in Classical.forall_intro aux let math_cast_aux (n:UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n) = FStar.Math.Lemmas.small_mod (UInt64.v n) (pow2 32) inline_for_extraction let gcm128_encrypt_opt_alloca key iv plain_b plain_len auth_b auth_bytes iv_b out_b tag_b keys_b hkeys_b scratch_b inout_b abytes_b = let h0 = get() in let lemma_uv_key () : Lemma (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) = length_aux keys_b; let db = get_downview keys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in le_bytes_to_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key)); assert (Seq.equal (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b))) (key_to_round_keys_LE AES_128 (Ghost.reveal key))); calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 keys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_key (); // Simplify the precondition for hkeys_b let lemma_uv_hkey () : Lemma (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in UV.as_seq h0 ub == le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) = length_aux5 hkeys_b; let db = get_downview hkeys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 hkeys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_hkey (); // Simplify the expression for the iv DV.length_eq (get_downview iv_b); length_aux4 iv_b; calc (==) { compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv); (==) { } le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b)); (==) { gcm_simplify2 iv_b h0 } le_bytes_to_quad32 (le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0)); (==) { le_bytes_to_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) } low_buffer_read TUInt8 TUInt128 h0 iv_b 0; }; // Compute length of biggest blocks of 6 * 128-bit blocks let len128x6 = UInt64.mul (plain_len / 96uL) 96uL in if len128x6 / 16uL >= 18uL then ( let len128_num = ((plain_len / 16uL) * 16uL) - len128x6 in // Casting to uint32 is here the equality math_cast_aux len128x6; math_cast_aux len128_num; let in128x6_b = B.sub plain_b 0ul (uint64_to_uint32 len128x6) in let out128x6_b = B.sub out_b 0ul (uint64_to_uint32 len128x6) in let in128_b = B.sub plain_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128x6' = UInt64.div len128x6 16uL in let len128_num' = UInt64.div len128_num 16uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b (uint64_to_uint32 len128x6); // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b (uint64_to_uint32 len128x6); assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ) else ( let len128x6 = 0ul in // Compute the size of the remaining 128-bit blocks let len128_num = ((plain_len / 16uL) * 16uL) in // Casting to uint32 is here the equality FStar.Math.Lemmas.small_mod (UInt64.v len128_num) pow2_32; let in128x6_b = B.sub plain_b 0ul len128x6 in let out128x6_b = B.sub out_b 0ul len128x6 in let in128_b = B.sub plain_b len128x6 (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b len128x6 (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128_num' = UInt64.div len128_num 16uL in let len128x6' = 0uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b len128x6; // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b len128x6; assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ); // Simplify post condition for tag let h_f = get() in gcm_simplify2 tag_b h_f let lemma_identical_uv (b:uint8_p) (h0 h1:HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures ( let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 b_u) (UV.as_seq h1 b_u))) = lemma_dv_equal Vale.Interop.Views.down_view8 b h0 h1; length_aux3 b (B.length b / 16); lemma_uv_equal Vale.Interop.Views.up_view128 (get_downview b) h0 h1
false
false
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val length_aux6 (b: uint8_p) : Lemma (B.length b = DV.length (get_downview b))
[]
Vale.Wrapper.X64.GCMencryptOpt.length_aux6
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> FStar.Pervasives.Lemma (ensures LowStar.Monotonic.Buffer.length b = LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview b))
{ "end_col": 33, "end_line": 762, "start_col": 4, "start_line": 762 }
FStar.Pervasives.Lemma
val lemma_same_seq_dv (h: HS.mem) (b: uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b)))
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_same_seq_dv (h:HS.mem) (b:uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) = let db = get_downview b in DV.length_eq db; let aux (i:nat{i < B.length b}) : Lemma (Seq.index (B.as_seq h b) i == Seq.index (DV.as_seq h db) i) = DV.as_seq_sel h db i; DV.get_sel h db i; Vale.Interop.Views.put8_reveal () in Classical.forall_intro aux
val lemma_same_seq_dv (h: HS.mem) (b: uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) let lemma_same_seq_dv (h: HS.mem) (b: uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) =
false
null
true
let db = get_downview b in DV.length_eq db; let aux (i: nat{i < B.length b}) : Lemma (Seq.index (B.as_seq h b) i == Seq.index (DV.as_seq h db) i) = DV.as_seq_sel h db i; DV.get_sel h db i; Vale.Interop.Views.put8_reveal () in Classical.forall_intro aux
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "lemma" ]
[ "FStar.Monotonic.HyperStack.mem", "Vale.Wrapper.X64.GCMencryptOpt.uint8_p", "FStar.Classical.forall_intro", "FStar.Integers.nat", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "FStar.UInt8.t", "LowStar.Buffer.trivial_preorder", "Prims.eq2", "FStar.Seq.Base.index", "LowStar.Monotonic.Buffer.as_seq", "LowStar.BufferView.Down.as_seq", "FStar.Integers.int_t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.Interop.Views.put8_reveal", "LowStar.BufferView.Down.get_sel", "LowStar.BufferView.Down.as_seq_sel", "LowStar.BufferView.Down.length_eq", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Arch.HeapTypes_s.TUInt8", "FStar.Seq.Base.equal" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) #reset-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" let math_aux (n:nat) : Lemma (n * 1 == n) = () let length_div (b:uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) = DV.length_eq (get_downview b) inline_for_extraction val gcm128_encrypt_opt': key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> auth_b:uint8_p -> auth_bytes:uint64 -> auth_num:uint64 -> keys_b:uint8_p -> iv_b:uint8_p -> hkeys_b:uint8_p -> abytes_b:uint8_p -> in128x6_b:uint8_p -> out128x6_b:uint8_p -> len128x6:uint64 -> in128_b:uint8_p -> out128_b:uint8_p -> len128_num:uint64 -> inout_b:uint8_p -> plain_num:uint64 -> scratch_b:uint8_p -> tag_b:uint8_p -> Stack unit (requires fun h0 -> B.disjoint tag_b keys_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b abytes_b /\ B.disjoint tag_b iv_b /\ B.disjoint tag_b in128x6_b /\ B.disjoint tag_b out128x6_b /\ B.disjoint tag_b in128_b /\ B.disjoint tag_b out128_b /\ B.disjoint tag_b inout_b /\ B.disjoint tag_b scratch_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b auth_b /\ B.disjoint iv_b abytes_b /\ B.disjoint iv_b in128x6_b /\ B.disjoint iv_b out128x6_b /\ B.disjoint iv_b in128_b /\ B.disjoint iv_b out128_b /\ B.disjoint iv_b inout_b /\ B.disjoint iv_b scratch_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint scratch_b in128x6_b /\ B.disjoint scratch_b out128x6_b /\ B.disjoint scratch_b in128_b /\ B.disjoint scratch_b out128_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b abytes_b /\ B.disjoint inout_b in128x6_b /\ B.disjoint inout_b out128x6_b /\ B.disjoint inout_b in128_b /\ B.disjoint inout_b out128_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint out128x6_b keys_b /\ B.disjoint out128x6_b auth_b /\ B.disjoint out128x6_b abytes_b /\ B.disjoint out128x6_b hkeys_b /\ B.disjoint out128x6_b in128_b /\ B.disjoint out128x6_b inout_b /\ B.disjoint in128x6_b keys_b /\ B.disjoint in128x6_b auth_b /\ B.disjoint in128x6_b abytes_b /\ B.disjoint in128x6_b hkeys_b /\ B.disjoint in128x6_b in128_b /\ B.disjoint in128x6_b inout_b /\ B.disjoint out128_b keys_b /\ B.disjoint out128_b auth_b /\ B.disjoint out128_b abytes_b /\ B.disjoint out128_b hkeys_b /\ B.disjoint out128_b in128x6_b /\ B.disjoint out128_b out128x6_b /\ B.disjoint out128_b inout_b /\ B.disjoint in128_b keys_b /\ B.disjoint in128_b auth_b /\ B.disjoint in128_b abytes_b /\ B.disjoint in128_b hkeys_b /\ B.disjoint in128_b in128x6_b /\ B.disjoint in128_b out128x6_b /\ B.disjoint in128_b inout_b /\ B.disjoint keys_b abytes_b /\ B.disjoint hkeys_b auth_b /\ B.disjoint hkeys_b abytes_b /\ B.disjoint auth_b abytes_b /\ B.disjoint keys_b auth_b /\ disjoint_or_eq in128x6_b out128x6_b /\ disjoint_or_eq in128_b out128_b /\ disjoint_or_eq keys_b hkeys_b /\ B.live h0 auth_b /\ B.live h0 abytes_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 in128x6_b /\ B.live h0 out128x6_b /\ B.live h0 in128_b /\ B.live h0 out128_b /\ B.live h0 inout_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.length auth_b = 16 * UInt64.v auth_num /\ B.length abytes_b == 16 /\ B.length iv_b = 16 /\ B.length in128x6_b == 16 * UInt64.v len128x6 /\ B.length out128x6_b == B.length in128x6_b /\ B.length in128_b == 16 * UInt64.v len128_num /\ B.length out128_b == B.length in128_b /\ B.length inout_b == 16 /\ B.length scratch_b == 144 /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ UInt64.v plain_num < pow2_32 /\ UInt64.v auth_bytes < pow2_32 /\ UInt64.v len128x6 % 6 == 0 /\ (UInt64.v len128x6 > 0 ==> UInt64.v len128x6 >= 18) /\ 12 + UInt64.v len128x6 + 6 < pow2_32 /\ UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) <= UInt64.v plain_num /\ UInt64.v plain_num < UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) + 128/8 /\ UInt64.v auth_num * (128/8) <= UInt64.v auth_bytes /\ UInt64.v auth_bytes < UInt64.v auth_num * (128/8) + 128/8 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) /\ (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)))) /\ (length_div iv_b; (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out128x6_b) (B.loc_union (B.loc_buffer out128_b) (B.loc_buffer inout_b)))))) h0 h1 /\ ((UInt64.v plain_num) < pow2_32 /\ (UInt64.v auth_bytes) < pow2_32 /\ ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_num) in let cipher_out = Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_num) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_num); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_bytes) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ is_aes_key AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in cipher == cipher_bytes /\ (length_div tag_b; le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h1 tag_b 0) == tag )))) ) #push-options "--z3cliopt smt.arith.nl=true --retry 3 --z3rlimit 800 --ext compat:normalizer_memo_ignore_cfg" #restart-solver inline_for_extraction let gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b = let h0 = get() in B.disjoint_neq iv_b auth_b; B.disjoint_neq iv_b keys_b; B.disjoint_neq iv_b hkeys_b; B.disjoint_neq iv_b abytes_b; B.disjoint_neq iv_b in128x6_b; B.disjoint_neq iv_b out128x6_b; B.disjoint_neq iv_b in128_b; B.disjoint_neq iv_b out128_b; B.disjoint_neq iv_b inout_b; B.disjoint_neq iv_b scratch_b; B.disjoint_neq iv_b tag_b; DV.length_eq (get_downview auth_b); DV.length_eq (get_downview keys_b); DV.length_eq (get_downview iv_b); DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview abytes_b); DV.length_eq (get_downview in128x6_b); DV.length_eq (get_downview out128x6_b); DV.length_eq (get_downview in128_b); DV.length_eq (get_downview out128_b); DV.length_eq (get_downview inout_b); DV.length_eq (get_downview scratch_b); DV.length_eq (get_downview tag_b); math_aux (B.length auth_b); math_aux (B.length keys_b); math_aux (B.length iv_b); math_aux (B.length hkeys_b); math_aux (B.length in128x6_b); math_aux (B.length scratch_b); math_aux (B.length out128_b); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v auth_num) 16; assert_norm (176 % 16 = 0); assert_norm (16 % 16 = 0); assert_norm (144 % 16 = 0); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128x6) 16; FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128_num) 16; calc (<=) { 256 * ((16 * UInt64.v len128_num) / 16); (==) { FStar.Math.Lemmas.cancel_mul_div (UInt64.v len128_num) 16 } 256 * (UInt64.v len128_num); ( <= ) { assert_norm (256 <= 4096); FStar.Math.Lemmas.lemma_mult_le_right (UInt64.v len128_num) 256 4096 } 4096 * (UInt64.v len128_num); }; assert (DV.length (get_downview tag_b) % 16 = 0); assert (DV.length (get_downview scratch_b) % 16 = 0); assert (DV.length (get_downview out128_b) % 16 = 0); as_vale_buffer_len #TUInt8 #TUInt128 auth_b; as_vale_buffer_len #TUInt8 #TUInt128 keys_b; as_vale_buffer_len #TUInt8 #TUInt128 iv_b; as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b; as_vale_buffer_len #TUInt8 #TUInt128 abytes_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128_b; as_vale_buffer_len #TUInt8 #TUInt128 inout_b; as_vale_buffer_len #TUInt8 #TUInt128 scratch_b; as_vale_buffer_len #TUInt8 #TUInt128 tag_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 auth_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 inout_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 keys_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b; let (x, _) = gcm128_encrypt_opt key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b () in let h1 = get() in () #pop-options inline_for_extraction val gcm128_encrypt_opt_alloca: key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> plain_b:uint8_p -> plain_len:uint64 -> auth_b:uint8_p -> auth_len:uint64 -> iv_b:uint8_p -> out_b:uint8_p -> tag_b:uint8_p -> keys_b:uint8_p -> hkeys_b:uint8_p -> scratch_b:uint8_p -> inout_b : uint8_p -> abytes_b : uint8_p -> Stack unit (requires fun h0 -> B.disjoint scratch_b tag_b /\ B.disjoint scratch_b out_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint scratch_b plain_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b iv_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint inout_b tag_b /\ B.disjoint inout_b out_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint inout_b plain_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b iv_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b abytes_b /\ B.disjoint abytes_b tag_b /\ B.disjoint abytes_b out_b /\ B.disjoint abytes_b hkeys_b /\ B.disjoint abytes_b plain_b /\ B.disjoint abytes_b auth_b /\ B.disjoint abytes_b iv_b /\ B.disjoint abytes_b keys_b /\ B.disjoint tag_b out_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint tag_b plain_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b iv_b /\ disjoint_or_eq tag_b keys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b out_b /\ B.disjoint iv_b plain_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint iv_b auth_b /\ B.disjoint out_b keys_b /\ B.disjoint out_b hkeys_b /\ B.disjoint out_b auth_b /\ disjoint_or_eq out_b plain_b /\ B.disjoint plain_b keys_b /\ B.disjoint plain_b hkeys_b /\ B.disjoint plain_b auth_b /\ disjoint_or_eq keys_b hkeys_b /\ B.disjoint keys_b auth_b /\ B.disjoint hkeys_b auth_b /\ B.live h0 auth_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 out_b /\ B.live h0 plain_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.live h0 inout_b /\ B.live h0 abytes_b /\ B.length auth_b = (UInt64.v auth_len / 16) * 16 /\ B.length iv_b = 16 /\ B.length plain_b = (UInt64.v plain_len / 16) * 16 /\ B.length out_b = B.length plain_b /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ B.length scratch_b = 144 /\ B.length inout_b = 16 /\ B.length abytes_b = 16 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (Seq.equal (B.as_seq h0 keys_b) (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key))))) /\ hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0))) /\ (le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out_b) (B.loc_buffer inout_b))))) h0 h1 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ (let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in Seq.length plain_bytes < pow2_32 /\ Seq.length auth_bytes < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h1 tag_b)) tag ) ))
false
false
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_same_seq_dv (h: HS.mem) (b: uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b)))
[]
Vale.Wrapper.X64.GCMencryptOpt.lemma_same_seq_dv
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> b: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.equal (LowStar.Monotonic.Buffer.as_seq h b) (LowStar.BufferView.Down.as_seq h (Vale.Interop.Types.get_downview b)))
{ "end_col": 31, "end_line": 425, "start_col": 61, "start_line": 418 }
FStar.Pervasives.Lemma
val lemma_identical_uv (b: uint8_p) (h0 h1: HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures (let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 b_u) (UV.as_seq h1 b_u)))
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_identical_uv (b:uint8_p) (h0 h1:HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures ( let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 b_u) (UV.as_seq h1 b_u))) = lemma_dv_equal Vale.Interop.Views.down_view8 b h0 h1; length_aux3 b (B.length b / 16); lemma_uv_equal Vale.Interop.Views.up_view128 (get_downview b) h0 h1
val lemma_identical_uv (b: uint8_p) (h0 h1: HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures (let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 b_u) (UV.as_seq h1 b_u))) let lemma_identical_uv (b: uint8_p) (h0 h1: HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures (let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 b_u) (UV.as_seq h1 b_u))) =
false
null
true
lemma_dv_equal Vale.Interop.Views.down_view8 b h0 h1; length_aux3 b (B.length b / 16); lemma_uv_equal Vale.Interop.Views.up_view128 (get_downview b) h0 h1
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "lemma" ]
[ "Vale.Wrapper.X64.GCMencryptOpt.uint8_p", "FStar.Monotonic.HyperStack.mem", "Vale.Lib.BufferViewHelpers.lemma_uv_equal", "FStar.UInt8.t", "Vale.Def.Types_s.quad32", "Vale.Interop.Views.up_view128", "Vale.Interop.Types.get_downview", "Vale.Arch.HeapTypes_s.TUInt8", "LowStar.Buffer.trivial_preorder", "Prims.unit", "Vale.Wrapper.X64.GCMencryptOpt.length_aux3", "FStar.Integers.op_Slash", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "Vale.Lib.BufferViewHelpers.lemma_dv_equal", "Vale.Interop.Views.down_view8", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Integers.op_Percent", "FStar.Seq.Base.equal", "LowStar.Monotonic.Buffer.as_seq", "Prims.squash", "LowStar.BufferView.Up.as_seq", "LowStar.BufferView.Up.buffer", "LowStar.BufferView.Up.mk_buffer", "LowStar.BufferView.Down.buffer", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) #reset-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" let math_aux (n:nat) : Lemma (n * 1 == n) = () let length_div (b:uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) = DV.length_eq (get_downview b) inline_for_extraction val gcm128_encrypt_opt': key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> auth_b:uint8_p -> auth_bytes:uint64 -> auth_num:uint64 -> keys_b:uint8_p -> iv_b:uint8_p -> hkeys_b:uint8_p -> abytes_b:uint8_p -> in128x6_b:uint8_p -> out128x6_b:uint8_p -> len128x6:uint64 -> in128_b:uint8_p -> out128_b:uint8_p -> len128_num:uint64 -> inout_b:uint8_p -> plain_num:uint64 -> scratch_b:uint8_p -> tag_b:uint8_p -> Stack unit (requires fun h0 -> B.disjoint tag_b keys_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b abytes_b /\ B.disjoint tag_b iv_b /\ B.disjoint tag_b in128x6_b /\ B.disjoint tag_b out128x6_b /\ B.disjoint tag_b in128_b /\ B.disjoint tag_b out128_b /\ B.disjoint tag_b inout_b /\ B.disjoint tag_b scratch_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b auth_b /\ B.disjoint iv_b abytes_b /\ B.disjoint iv_b in128x6_b /\ B.disjoint iv_b out128x6_b /\ B.disjoint iv_b in128_b /\ B.disjoint iv_b out128_b /\ B.disjoint iv_b inout_b /\ B.disjoint iv_b scratch_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint scratch_b in128x6_b /\ B.disjoint scratch_b out128x6_b /\ B.disjoint scratch_b in128_b /\ B.disjoint scratch_b out128_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b abytes_b /\ B.disjoint inout_b in128x6_b /\ B.disjoint inout_b out128x6_b /\ B.disjoint inout_b in128_b /\ B.disjoint inout_b out128_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint out128x6_b keys_b /\ B.disjoint out128x6_b auth_b /\ B.disjoint out128x6_b abytes_b /\ B.disjoint out128x6_b hkeys_b /\ B.disjoint out128x6_b in128_b /\ B.disjoint out128x6_b inout_b /\ B.disjoint in128x6_b keys_b /\ B.disjoint in128x6_b auth_b /\ B.disjoint in128x6_b abytes_b /\ B.disjoint in128x6_b hkeys_b /\ B.disjoint in128x6_b in128_b /\ B.disjoint in128x6_b inout_b /\ B.disjoint out128_b keys_b /\ B.disjoint out128_b auth_b /\ B.disjoint out128_b abytes_b /\ B.disjoint out128_b hkeys_b /\ B.disjoint out128_b in128x6_b /\ B.disjoint out128_b out128x6_b /\ B.disjoint out128_b inout_b /\ B.disjoint in128_b keys_b /\ B.disjoint in128_b auth_b /\ B.disjoint in128_b abytes_b /\ B.disjoint in128_b hkeys_b /\ B.disjoint in128_b in128x6_b /\ B.disjoint in128_b out128x6_b /\ B.disjoint in128_b inout_b /\ B.disjoint keys_b abytes_b /\ B.disjoint hkeys_b auth_b /\ B.disjoint hkeys_b abytes_b /\ B.disjoint auth_b abytes_b /\ B.disjoint keys_b auth_b /\ disjoint_or_eq in128x6_b out128x6_b /\ disjoint_or_eq in128_b out128_b /\ disjoint_or_eq keys_b hkeys_b /\ B.live h0 auth_b /\ B.live h0 abytes_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 in128x6_b /\ B.live h0 out128x6_b /\ B.live h0 in128_b /\ B.live h0 out128_b /\ B.live h0 inout_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.length auth_b = 16 * UInt64.v auth_num /\ B.length abytes_b == 16 /\ B.length iv_b = 16 /\ B.length in128x6_b == 16 * UInt64.v len128x6 /\ B.length out128x6_b == B.length in128x6_b /\ B.length in128_b == 16 * UInt64.v len128_num /\ B.length out128_b == B.length in128_b /\ B.length inout_b == 16 /\ B.length scratch_b == 144 /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ UInt64.v plain_num < pow2_32 /\ UInt64.v auth_bytes < pow2_32 /\ UInt64.v len128x6 % 6 == 0 /\ (UInt64.v len128x6 > 0 ==> UInt64.v len128x6 >= 18) /\ 12 + UInt64.v len128x6 + 6 < pow2_32 /\ UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) <= UInt64.v plain_num /\ UInt64.v plain_num < UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) + 128/8 /\ UInt64.v auth_num * (128/8) <= UInt64.v auth_bytes /\ UInt64.v auth_bytes < UInt64.v auth_num * (128/8) + 128/8 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) /\ (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)))) /\ (length_div iv_b; (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out128x6_b) (B.loc_union (B.loc_buffer out128_b) (B.loc_buffer inout_b)))))) h0 h1 /\ ((UInt64.v plain_num) < pow2_32 /\ (UInt64.v auth_bytes) < pow2_32 /\ ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_num) in let cipher_out = Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_num) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_num); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_bytes) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ is_aes_key AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in cipher == cipher_bytes /\ (length_div tag_b; le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h1 tag_b 0) == tag )))) ) #push-options "--z3cliopt smt.arith.nl=true --retry 3 --z3rlimit 800 --ext compat:normalizer_memo_ignore_cfg" #restart-solver inline_for_extraction let gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b = let h0 = get() in B.disjoint_neq iv_b auth_b; B.disjoint_neq iv_b keys_b; B.disjoint_neq iv_b hkeys_b; B.disjoint_neq iv_b abytes_b; B.disjoint_neq iv_b in128x6_b; B.disjoint_neq iv_b out128x6_b; B.disjoint_neq iv_b in128_b; B.disjoint_neq iv_b out128_b; B.disjoint_neq iv_b inout_b; B.disjoint_neq iv_b scratch_b; B.disjoint_neq iv_b tag_b; DV.length_eq (get_downview auth_b); DV.length_eq (get_downview keys_b); DV.length_eq (get_downview iv_b); DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview abytes_b); DV.length_eq (get_downview in128x6_b); DV.length_eq (get_downview out128x6_b); DV.length_eq (get_downview in128_b); DV.length_eq (get_downview out128_b); DV.length_eq (get_downview inout_b); DV.length_eq (get_downview scratch_b); DV.length_eq (get_downview tag_b); math_aux (B.length auth_b); math_aux (B.length keys_b); math_aux (B.length iv_b); math_aux (B.length hkeys_b); math_aux (B.length in128x6_b); math_aux (B.length scratch_b); math_aux (B.length out128_b); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v auth_num) 16; assert_norm (176 % 16 = 0); assert_norm (16 % 16 = 0); assert_norm (144 % 16 = 0); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128x6) 16; FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128_num) 16; calc (<=) { 256 * ((16 * UInt64.v len128_num) / 16); (==) { FStar.Math.Lemmas.cancel_mul_div (UInt64.v len128_num) 16 } 256 * (UInt64.v len128_num); ( <= ) { assert_norm (256 <= 4096); FStar.Math.Lemmas.lemma_mult_le_right (UInt64.v len128_num) 256 4096 } 4096 * (UInt64.v len128_num); }; assert (DV.length (get_downview tag_b) % 16 = 0); assert (DV.length (get_downview scratch_b) % 16 = 0); assert (DV.length (get_downview out128_b) % 16 = 0); as_vale_buffer_len #TUInt8 #TUInt128 auth_b; as_vale_buffer_len #TUInt8 #TUInt128 keys_b; as_vale_buffer_len #TUInt8 #TUInt128 iv_b; as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b; as_vale_buffer_len #TUInt8 #TUInt128 abytes_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128_b; as_vale_buffer_len #TUInt8 #TUInt128 inout_b; as_vale_buffer_len #TUInt8 #TUInt128 scratch_b; as_vale_buffer_len #TUInt8 #TUInt128 tag_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 auth_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 inout_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 keys_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b; let (x, _) = gcm128_encrypt_opt key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b () in let h1 = get() in () #pop-options inline_for_extraction val gcm128_encrypt_opt_alloca: key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> plain_b:uint8_p -> plain_len:uint64 -> auth_b:uint8_p -> auth_len:uint64 -> iv_b:uint8_p -> out_b:uint8_p -> tag_b:uint8_p -> keys_b:uint8_p -> hkeys_b:uint8_p -> scratch_b:uint8_p -> inout_b : uint8_p -> abytes_b : uint8_p -> Stack unit (requires fun h0 -> B.disjoint scratch_b tag_b /\ B.disjoint scratch_b out_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint scratch_b plain_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b iv_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint inout_b tag_b /\ B.disjoint inout_b out_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint inout_b plain_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b iv_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b abytes_b /\ B.disjoint abytes_b tag_b /\ B.disjoint abytes_b out_b /\ B.disjoint abytes_b hkeys_b /\ B.disjoint abytes_b plain_b /\ B.disjoint abytes_b auth_b /\ B.disjoint abytes_b iv_b /\ B.disjoint abytes_b keys_b /\ B.disjoint tag_b out_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint tag_b plain_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b iv_b /\ disjoint_or_eq tag_b keys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b out_b /\ B.disjoint iv_b plain_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint iv_b auth_b /\ B.disjoint out_b keys_b /\ B.disjoint out_b hkeys_b /\ B.disjoint out_b auth_b /\ disjoint_or_eq out_b plain_b /\ B.disjoint plain_b keys_b /\ B.disjoint plain_b hkeys_b /\ B.disjoint plain_b auth_b /\ disjoint_or_eq keys_b hkeys_b /\ B.disjoint keys_b auth_b /\ B.disjoint hkeys_b auth_b /\ B.live h0 auth_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 out_b /\ B.live h0 plain_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.live h0 inout_b /\ B.live h0 abytes_b /\ B.length auth_b = (UInt64.v auth_len / 16) * 16 /\ B.length iv_b = 16 /\ B.length plain_b = (UInt64.v plain_len / 16) * 16 /\ B.length out_b = B.length plain_b /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ B.length scratch_b = 144 /\ B.length inout_b = 16 /\ B.length abytes_b = 16 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (Seq.equal (B.as_seq h0 keys_b) (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key))))) /\ hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0))) /\ (le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out_b) (B.loc_buffer inout_b))))) h0 h1 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ (let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in Seq.length plain_bytes < pow2_32 /\ Seq.length auth_bytes < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h1 tag_b)) tag ) )) let lemma_same_seq_dv (h:HS.mem) (b:uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) = let db = get_downview b in DV.length_eq db; let aux (i:nat{i < B.length b}) : Lemma (Seq.index (B.as_seq h b) i == Seq.index (DV.as_seq h db) i) = DV.as_seq_sel h db i; DV.get_sel h db i; Vale.Interop.Views.put8_reveal () in Classical.forall_intro aux let lemma_uv_split (h:HS.mem) (b:uint8_p) (n:UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures ( let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs) ) = let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in calc (==) { Seq.length split_bs; (==) { } Seq.length (UV.as_seq h b1_u) + Seq.length (UV.as_seq h b2_u); (==) { UV.length_eq b1_u; UV.length_eq b2_u } DV.length b1_d / 16 + DV.length b2_d / 16; (==) { DV.length_eq b1_d; DV.length_eq b2_d; math_aux (B.length b1); math_aux (B.length b2) } B.length b1 / 16 + B.length b2 / 16; (==) { } B.length b / 16; (==) { DV.length_eq b_d; UV.length_eq b_u; math_aux (B.length b) } Seq.length bs; }; assert (Seq.length bs == Seq.length split_bs); let aux (i:nat{ i < Seq.length bs}) : Lemma (Seq.index bs i = Seq.index split_bs i) = UV.length_eq b_u; lemma_same_seq_dv h b; calc (==) { Seq.index bs i; (==) { UV.as_seq_sel h b_u i } UV.sel h b_u i; (==) { UV.get_sel h b_u i } Vale.Interop.Views.get128 (Seq.slice (DV.as_seq h b_d) (i * 16) (i * 16 + 16)); (==) { lemma_same_seq_dv h b } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b) (i * 16) (i * 16 + 16)); (==) { assert (Seq.equal (B.as_seq h b) (Seq.append (B.as_seq h b1) (B.as_seq h b2))) } Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); }; if i < Seq.length (UV.as_seq h b1_u) then ( lemma_same_seq_dv h b1; UV.length_eq b1_u; calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b1) (i * 16) (i * 16 + 16)); (==) { UV.get_sel h b1_u i } UV.sel h b1_u i; (==) { UV.as_seq_sel h b1_u i } Seq.index (UV.as_seq h b1_u) i; (==) { } Seq.index split_bs i; } ) else ( lemma_same_seq_dv h b2; UV.length_eq b2_u; let j = i - UV.length b1_u in calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b2) (j * 16) (j * 16 + 16)); (==) { UV.get_sel h b2_u j } UV.sel h b2_u j; (==) { UV.as_seq_sel h b2_u j } Seq.index (UV.as_seq h b2_u) j; (==) { } Seq.index split_bs i; } ) in Classical.forall_intro aux let math_cast_aux (n:UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n) = FStar.Math.Lemmas.small_mod (UInt64.v n) (pow2 32) inline_for_extraction let gcm128_encrypt_opt_alloca key iv plain_b plain_len auth_b auth_bytes iv_b out_b tag_b keys_b hkeys_b scratch_b inout_b abytes_b = let h0 = get() in let lemma_uv_key () : Lemma (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) = length_aux keys_b; let db = get_downview keys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in le_bytes_to_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key)); assert (Seq.equal (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b))) (key_to_round_keys_LE AES_128 (Ghost.reveal key))); calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 keys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_key (); // Simplify the precondition for hkeys_b let lemma_uv_hkey () : Lemma (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in UV.as_seq h0 ub == le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) = length_aux5 hkeys_b; let db = get_downview hkeys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 hkeys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_hkey (); // Simplify the expression for the iv DV.length_eq (get_downview iv_b); length_aux4 iv_b; calc (==) { compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv); (==) { } le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b)); (==) { gcm_simplify2 iv_b h0 } le_bytes_to_quad32 (le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0)); (==) { le_bytes_to_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) } low_buffer_read TUInt8 TUInt128 h0 iv_b 0; }; // Compute length of biggest blocks of 6 * 128-bit blocks let len128x6 = UInt64.mul (plain_len / 96uL) 96uL in if len128x6 / 16uL >= 18uL then ( let len128_num = ((plain_len / 16uL) * 16uL) - len128x6 in // Casting to uint32 is here the equality math_cast_aux len128x6; math_cast_aux len128_num; let in128x6_b = B.sub plain_b 0ul (uint64_to_uint32 len128x6) in let out128x6_b = B.sub out_b 0ul (uint64_to_uint32 len128x6) in let in128_b = B.sub plain_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128x6' = UInt64.div len128x6 16uL in let len128_num' = UInt64.div len128_num 16uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b (uint64_to_uint32 len128x6); // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b (uint64_to_uint32 len128x6); assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ) else ( let len128x6 = 0ul in // Compute the size of the remaining 128-bit blocks let len128_num = ((plain_len / 16uL) * 16uL) in // Casting to uint32 is here the equality FStar.Math.Lemmas.small_mod (UInt64.v len128_num) pow2_32; let in128x6_b = B.sub plain_b 0ul len128x6 in let out128x6_b = B.sub out_b 0ul len128x6 in let in128_b = B.sub plain_b len128x6 (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b len128x6 (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128_num' = UInt64.div len128_num 16uL in let len128x6' = 0uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b len128x6; // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b len128x6; assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ); // Simplify post condition for tag let h_f = get() in gcm_simplify2 tag_b h_f let lemma_identical_uv (b:uint8_p) (h0 h1:HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures ( let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in
false
false
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_identical_uv (b: uint8_p) (h0 h1: HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures (let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 b_u) (UV.as_seq h1 b_u)))
[]
Vale.Wrapper.X64.GCMencryptOpt.lemma_identical_uv
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.length b % 16 = 0 /\ FStar.Seq.Base.equal (LowStar.Monotonic.Buffer.as_seq h0 b) (LowStar.Monotonic.Buffer.as_seq h1 b)) (ensures (let b_d = Vale.Interop.Types.get_downview b in [@@ FStar.Pervasives.inline_let ]let _ = Vale.Wrapper.X64.GCMencryptOpt.length_aux3 b (LowStar.Monotonic.Buffer.length b / 16) in let b_u = LowStar.BufferView.Up.mk_buffer b_d Vale.Interop.Views.up_view128 in FStar.Seq.Base.equal (LowStar.BufferView.Up.as_seq h0 b_u) (LowStar.BufferView.Up.as_seq h1 b_u)))
{ "end_col": 71, "end_line": 758, "start_col": 4, "start_line": 756 }
FStar.Pervasives.Lemma
val lemma_slice_uv_extra (b b_start b_extra: uint8_p) (h: HS.mem) : Lemma (requires B.length b_start = (B.length b / 16) * 16 /\ b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\ Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b))) (ensures (let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b))))
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_slice_uv_extra (b:uint8_p) (b_start:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma (requires B.length b_start = B.length b / 16 * 16 /\ b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\ Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b)) ) (ensures ( let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b)) )) = let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in let b_f = seq_uint8_to_seq_nat8 (B.as_seq h b) in // if B.length b > B.length b_start then ( calc (==) { sf; (==) { DV.length_eq b_start_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_start h; le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_start_u) } wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (UV.as_seq h b_extra_u))) (B.length b); (==) { DV.length_eq b_extra_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_extra h; le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_extra_u) } wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))))) (B.length b); (==) { append_distributes_le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) } wrap_slice (Seq.append (le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))) (le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))))) (B.length b); (==) { le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)); le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)) } wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start)) (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) (B.length b); (==) { Seq.lemma_eq_intro b_f (wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start)) (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) (B.length b)) } b_f; }
val lemma_slice_uv_extra (b b_start b_extra: uint8_p) (h: HS.mem) : Lemma (requires B.length b_start = (B.length b / 16) * 16 /\ b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\ Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b))) (ensures (let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b)))) let lemma_slice_uv_extra (b b_start b_extra: uint8_p) (h: HS.mem) : Lemma (requires B.length b_start = (B.length b / 16) * 16 /\ b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\ Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b))) (ensures (let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b)))) =
false
null
true
let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in let b_f = seq_uint8_to_seq_nat8 (B.as_seq h b) in calc ( == ) { sf; ( == ) { (DV.length_eq b_start_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_start h; le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_start_u)) } wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (UV.as_seq h b_extra_u))) (B.length b); ( == ) { (DV.length_eq b_extra_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_extra h; le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_extra_u)) } wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))))) (B.length b); ( == ) { append_distributes_le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 ( B.as_seq h b_start))) (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) } wrap_slice (Seq.append (le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))) (le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)) ))) (B.length b); ( == ) { (le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)); le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) } wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start)) (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) (B.length b); ( == ) { Seq.lemma_eq_intro b_f (wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start)) (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) (B.length b)) } b_f; }
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "lemma" ]
[ "Vale.Wrapper.X64.GCMencryptOpt.uint8_p", "FStar.Monotonic.HyperStack.mem", "FStar.Calc.calc_finish", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Prims.eq2", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Vale.Wrapper.X64.GCMencryptOpt.wrap_slice", "Vale.Def.Words_s.nat8", "FStar.Seq.Base.append", "Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8", "LowStar.Monotonic.Buffer.as_seq", "FStar.UInt8.t", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.length", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Vale.Def.Types_s.quad32", "LowStar.BufferView.Up.as_seq", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes", "Vale.SHA.Simplify_Sha.lemma_seq_nat8_le_seq_quad32_to_bytes_uint32", "LowStar.BufferView.Down.length_eq", "Prims.squash", "Vale.Arch.Types.append_distributes_le_seq_quad32_to_bytes", "Vale.Arch.Types.le_seq_quad32_to_bytes_to_seq_quad32", "FStar.Seq.Base.lemma_eq_intro", "LowStar.BufferView.Up.buffer", "LowStar.BufferView.Up.mk_buffer", "Vale.Interop.Views.up_view128", "Vale.Wrapper.X64.GCMencryptOpt.length_aux6", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Arch.HeapTypes_s.TUInt8", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Integers.op_Star", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Integers.op_Slash", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.gsub", "FStar.UInt32.__uint_to_t", "FStar.UInt32.uint_to_t", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "FStar.Pervasives.pattern" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) #reset-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" let math_aux (n:nat) : Lemma (n * 1 == n) = () let length_div (b:uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) = DV.length_eq (get_downview b) inline_for_extraction val gcm128_encrypt_opt': key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> auth_b:uint8_p -> auth_bytes:uint64 -> auth_num:uint64 -> keys_b:uint8_p -> iv_b:uint8_p -> hkeys_b:uint8_p -> abytes_b:uint8_p -> in128x6_b:uint8_p -> out128x6_b:uint8_p -> len128x6:uint64 -> in128_b:uint8_p -> out128_b:uint8_p -> len128_num:uint64 -> inout_b:uint8_p -> plain_num:uint64 -> scratch_b:uint8_p -> tag_b:uint8_p -> Stack unit (requires fun h0 -> B.disjoint tag_b keys_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b abytes_b /\ B.disjoint tag_b iv_b /\ B.disjoint tag_b in128x6_b /\ B.disjoint tag_b out128x6_b /\ B.disjoint tag_b in128_b /\ B.disjoint tag_b out128_b /\ B.disjoint tag_b inout_b /\ B.disjoint tag_b scratch_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b auth_b /\ B.disjoint iv_b abytes_b /\ B.disjoint iv_b in128x6_b /\ B.disjoint iv_b out128x6_b /\ B.disjoint iv_b in128_b /\ B.disjoint iv_b out128_b /\ B.disjoint iv_b inout_b /\ B.disjoint iv_b scratch_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint scratch_b in128x6_b /\ B.disjoint scratch_b out128x6_b /\ B.disjoint scratch_b in128_b /\ B.disjoint scratch_b out128_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b abytes_b /\ B.disjoint inout_b in128x6_b /\ B.disjoint inout_b out128x6_b /\ B.disjoint inout_b in128_b /\ B.disjoint inout_b out128_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint out128x6_b keys_b /\ B.disjoint out128x6_b auth_b /\ B.disjoint out128x6_b abytes_b /\ B.disjoint out128x6_b hkeys_b /\ B.disjoint out128x6_b in128_b /\ B.disjoint out128x6_b inout_b /\ B.disjoint in128x6_b keys_b /\ B.disjoint in128x6_b auth_b /\ B.disjoint in128x6_b abytes_b /\ B.disjoint in128x6_b hkeys_b /\ B.disjoint in128x6_b in128_b /\ B.disjoint in128x6_b inout_b /\ B.disjoint out128_b keys_b /\ B.disjoint out128_b auth_b /\ B.disjoint out128_b abytes_b /\ B.disjoint out128_b hkeys_b /\ B.disjoint out128_b in128x6_b /\ B.disjoint out128_b out128x6_b /\ B.disjoint out128_b inout_b /\ B.disjoint in128_b keys_b /\ B.disjoint in128_b auth_b /\ B.disjoint in128_b abytes_b /\ B.disjoint in128_b hkeys_b /\ B.disjoint in128_b in128x6_b /\ B.disjoint in128_b out128x6_b /\ B.disjoint in128_b inout_b /\ B.disjoint keys_b abytes_b /\ B.disjoint hkeys_b auth_b /\ B.disjoint hkeys_b abytes_b /\ B.disjoint auth_b abytes_b /\ B.disjoint keys_b auth_b /\ disjoint_or_eq in128x6_b out128x6_b /\ disjoint_or_eq in128_b out128_b /\ disjoint_or_eq keys_b hkeys_b /\ B.live h0 auth_b /\ B.live h0 abytes_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 in128x6_b /\ B.live h0 out128x6_b /\ B.live h0 in128_b /\ B.live h0 out128_b /\ B.live h0 inout_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.length auth_b = 16 * UInt64.v auth_num /\ B.length abytes_b == 16 /\ B.length iv_b = 16 /\ B.length in128x6_b == 16 * UInt64.v len128x6 /\ B.length out128x6_b == B.length in128x6_b /\ B.length in128_b == 16 * UInt64.v len128_num /\ B.length out128_b == B.length in128_b /\ B.length inout_b == 16 /\ B.length scratch_b == 144 /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ UInt64.v plain_num < pow2_32 /\ UInt64.v auth_bytes < pow2_32 /\ UInt64.v len128x6 % 6 == 0 /\ (UInt64.v len128x6 > 0 ==> UInt64.v len128x6 >= 18) /\ 12 + UInt64.v len128x6 + 6 < pow2_32 /\ UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) <= UInt64.v plain_num /\ UInt64.v plain_num < UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) + 128/8 /\ UInt64.v auth_num * (128/8) <= UInt64.v auth_bytes /\ UInt64.v auth_bytes < UInt64.v auth_num * (128/8) + 128/8 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) /\ (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)))) /\ (length_div iv_b; (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out128x6_b) (B.loc_union (B.loc_buffer out128_b) (B.loc_buffer inout_b)))))) h0 h1 /\ ((UInt64.v plain_num) < pow2_32 /\ (UInt64.v auth_bytes) < pow2_32 /\ ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_num) in let cipher_out = Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_num) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_num); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_bytes) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ is_aes_key AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in cipher == cipher_bytes /\ (length_div tag_b; le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h1 tag_b 0) == tag )))) ) #push-options "--z3cliopt smt.arith.nl=true --retry 3 --z3rlimit 800 --ext compat:normalizer_memo_ignore_cfg" #restart-solver inline_for_extraction let gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b = let h0 = get() in B.disjoint_neq iv_b auth_b; B.disjoint_neq iv_b keys_b; B.disjoint_neq iv_b hkeys_b; B.disjoint_neq iv_b abytes_b; B.disjoint_neq iv_b in128x6_b; B.disjoint_neq iv_b out128x6_b; B.disjoint_neq iv_b in128_b; B.disjoint_neq iv_b out128_b; B.disjoint_neq iv_b inout_b; B.disjoint_neq iv_b scratch_b; B.disjoint_neq iv_b tag_b; DV.length_eq (get_downview auth_b); DV.length_eq (get_downview keys_b); DV.length_eq (get_downview iv_b); DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview abytes_b); DV.length_eq (get_downview in128x6_b); DV.length_eq (get_downview out128x6_b); DV.length_eq (get_downview in128_b); DV.length_eq (get_downview out128_b); DV.length_eq (get_downview inout_b); DV.length_eq (get_downview scratch_b); DV.length_eq (get_downview tag_b); math_aux (B.length auth_b); math_aux (B.length keys_b); math_aux (B.length iv_b); math_aux (B.length hkeys_b); math_aux (B.length in128x6_b); math_aux (B.length scratch_b); math_aux (B.length out128_b); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v auth_num) 16; assert_norm (176 % 16 = 0); assert_norm (16 % 16 = 0); assert_norm (144 % 16 = 0); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128x6) 16; FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128_num) 16; calc (<=) { 256 * ((16 * UInt64.v len128_num) / 16); (==) { FStar.Math.Lemmas.cancel_mul_div (UInt64.v len128_num) 16 } 256 * (UInt64.v len128_num); ( <= ) { assert_norm (256 <= 4096); FStar.Math.Lemmas.lemma_mult_le_right (UInt64.v len128_num) 256 4096 } 4096 * (UInt64.v len128_num); }; assert (DV.length (get_downview tag_b) % 16 = 0); assert (DV.length (get_downview scratch_b) % 16 = 0); assert (DV.length (get_downview out128_b) % 16 = 0); as_vale_buffer_len #TUInt8 #TUInt128 auth_b; as_vale_buffer_len #TUInt8 #TUInt128 keys_b; as_vale_buffer_len #TUInt8 #TUInt128 iv_b; as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b; as_vale_buffer_len #TUInt8 #TUInt128 abytes_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128_b; as_vale_buffer_len #TUInt8 #TUInt128 inout_b; as_vale_buffer_len #TUInt8 #TUInt128 scratch_b; as_vale_buffer_len #TUInt8 #TUInt128 tag_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 auth_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 inout_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 keys_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b; let (x, _) = gcm128_encrypt_opt key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b () in let h1 = get() in () #pop-options inline_for_extraction val gcm128_encrypt_opt_alloca: key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> plain_b:uint8_p -> plain_len:uint64 -> auth_b:uint8_p -> auth_len:uint64 -> iv_b:uint8_p -> out_b:uint8_p -> tag_b:uint8_p -> keys_b:uint8_p -> hkeys_b:uint8_p -> scratch_b:uint8_p -> inout_b : uint8_p -> abytes_b : uint8_p -> Stack unit (requires fun h0 -> B.disjoint scratch_b tag_b /\ B.disjoint scratch_b out_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint scratch_b plain_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b iv_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint inout_b tag_b /\ B.disjoint inout_b out_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint inout_b plain_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b iv_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b abytes_b /\ B.disjoint abytes_b tag_b /\ B.disjoint abytes_b out_b /\ B.disjoint abytes_b hkeys_b /\ B.disjoint abytes_b plain_b /\ B.disjoint abytes_b auth_b /\ B.disjoint abytes_b iv_b /\ B.disjoint abytes_b keys_b /\ B.disjoint tag_b out_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint tag_b plain_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b iv_b /\ disjoint_or_eq tag_b keys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b out_b /\ B.disjoint iv_b plain_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint iv_b auth_b /\ B.disjoint out_b keys_b /\ B.disjoint out_b hkeys_b /\ B.disjoint out_b auth_b /\ disjoint_or_eq out_b plain_b /\ B.disjoint plain_b keys_b /\ B.disjoint plain_b hkeys_b /\ B.disjoint plain_b auth_b /\ disjoint_or_eq keys_b hkeys_b /\ B.disjoint keys_b auth_b /\ B.disjoint hkeys_b auth_b /\ B.live h0 auth_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 out_b /\ B.live h0 plain_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.live h0 inout_b /\ B.live h0 abytes_b /\ B.length auth_b = (UInt64.v auth_len / 16) * 16 /\ B.length iv_b = 16 /\ B.length plain_b = (UInt64.v plain_len / 16) * 16 /\ B.length out_b = B.length plain_b /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ B.length scratch_b = 144 /\ B.length inout_b = 16 /\ B.length abytes_b = 16 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (Seq.equal (B.as_seq h0 keys_b) (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key))))) /\ hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0))) /\ (le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out_b) (B.loc_buffer inout_b))))) h0 h1 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ (let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in Seq.length plain_bytes < pow2_32 /\ Seq.length auth_bytes < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h1 tag_b)) tag ) )) let lemma_same_seq_dv (h:HS.mem) (b:uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) = let db = get_downview b in DV.length_eq db; let aux (i:nat{i < B.length b}) : Lemma (Seq.index (B.as_seq h b) i == Seq.index (DV.as_seq h db) i) = DV.as_seq_sel h db i; DV.get_sel h db i; Vale.Interop.Views.put8_reveal () in Classical.forall_intro aux let lemma_uv_split (h:HS.mem) (b:uint8_p) (n:UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures ( let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs) ) = let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in calc (==) { Seq.length split_bs; (==) { } Seq.length (UV.as_seq h b1_u) + Seq.length (UV.as_seq h b2_u); (==) { UV.length_eq b1_u; UV.length_eq b2_u } DV.length b1_d / 16 + DV.length b2_d / 16; (==) { DV.length_eq b1_d; DV.length_eq b2_d; math_aux (B.length b1); math_aux (B.length b2) } B.length b1 / 16 + B.length b2 / 16; (==) { } B.length b / 16; (==) { DV.length_eq b_d; UV.length_eq b_u; math_aux (B.length b) } Seq.length bs; }; assert (Seq.length bs == Seq.length split_bs); let aux (i:nat{ i < Seq.length bs}) : Lemma (Seq.index bs i = Seq.index split_bs i) = UV.length_eq b_u; lemma_same_seq_dv h b; calc (==) { Seq.index bs i; (==) { UV.as_seq_sel h b_u i } UV.sel h b_u i; (==) { UV.get_sel h b_u i } Vale.Interop.Views.get128 (Seq.slice (DV.as_seq h b_d) (i * 16) (i * 16 + 16)); (==) { lemma_same_seq_dv h b } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b) (i * 16) (i * 16 + 16)); (==) { assert (Seq.equal (B.as_seq h b) (Seq.append (B.as_seq h b1) (B.as_seq h b2))) } Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); }; if i < Seq.length (UV.as_seq h b1_u) then ( lemma_same_seq_dv h b1; UV.length_eq b1_u; calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b1) (i * 16) (i * 16 + 16)); (==) { UV.get_sel h b1_u i } UV.sel h b1_u i; (==) { UV.as_seq_sel h b1_u i } Seq.index (UV.as_seq h b1_u) i; (==) { } Seq.index split_bs i; } ) else ( lemma_same_seq_dv h b2; UV.length_eq b2_u; let j = i - UV.length b1_u in calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b2) (j * 16) (j * 16 + 16)); (==) { UV.get_sel h b2_u j } UV.sel h b2_u j; (==) { UV.as_seq_sel h b2_u j } Seq.index (UV.as_seq h b2_u) j; (==) { } Seq.index split_bs i; } ) in Classical.forall_intro aux let math_cast_aux (n:UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n) = FStar.Math.Lemmas.small_mod (UInt64.v n) (pow2 32) inline_for_extraction let gcm128_encrypt_opt_alloca key iv plain_b plain_len auth_b auth_bytes iv_b out_b tag_b keys_b hkeys_b scratch_b inout_b abytes_b = let h0 = get() in let lemma_uv_key () : Lemma (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) = length_aux keys_b; let db = get_downview keys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in le_bytes_to_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key)); assert (Seq.equal (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b))) (key_to_round_keys_LE AES_128 (Ghost.reveal key))); calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 keys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_key (); // Simplify the precondition for hkeys_b let lemma_uv_hkey () : Lemma (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in UV.as_seq h0 ub == le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) = length_aux5 hkeys_b; let db = get_downview hkeys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 hkeys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_hkey (); // Simplify the expression for the iv DV.length_eq (get_downview iv_b); length_aux4 iv_b; calc (==) { compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv); (==) { } le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b)); (==) { gcm_simplify2 iv_b h0 } le_bytes_to_quad32 (le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0)); (==) { le_bytes_to_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) } low_buffer_read TUInt8 TUInt128 h0 iv_b 0; }; // Compute length of biggest blocks of 6 * 128-bit blocks let len128x6 = UInt64.mul (plain_len / 96uL) 96uL in if len128x6 / 16uL >= 18uL then ( let len128_num = ((plain_len / 16uL) * 16uL) - len128x6 in // Casting to uint32 is here the equality math_cast_aux len128x6; math_cast_aux len128_num; let in128x6_b = B.sub plain_b 0ul (uint64_to_uint32 len128x6) in let out128x6_b = B.sub out_b 0ul (uint64_to_uint32 len128x6) in let in128_b = B.sub plain_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128x6' = UInt64.div len128x6 16uL in let len128_num' = UInt64.div len128_num 16uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b (uint64_to_uint32 len128x6); // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b (uint64_to_uint32 len128x6); assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ) else ( let len128x6 = 0ul in // Compute the size of the remaining 128-bit blocks let len128_num = ((plain_len / 16uL) * 16uL) in // Casting to uint32 is here the equality FStar.Math.Lemmas.small_mod (UInt64.v len128_num) pow2_32; let in128x6_b = B.sub plain_b 0ul len128x6 in let out128x6_b = B.sub out_b 0ul len128x6 in let in128_b = B.sub plain_b len128x6 (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b len128x6 (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128_num' = UInt64.div len128_num 16uL in let len128x6' = 0uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b len128x6; // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b len128x6; assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ); // Simplify post condition for tag let h_f = get() in gcm_simplify2 tag_b h_f let lemma_identical_uv (b:uint8_p) (h0 h1:HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures ( let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 b_u) (UV.as_seq h1 b_u))) = lemma_dv_equal Vale.Interop.Views.down_view8 b h0 h1; length_aux3 b (B.length b / 16); lemma_uv_equal Vale.Interop.Views.up_view128 (get_downview b) h0 h1 let length_aux6 (b:uint8_p) : Lemma (B.length b = DV.length (get_downview b)) = DV.length_eq (get_downview b) #push-options "--z3cliopt smt.arith.nl=true" let lemma_slice_uv_extra (b:uint8_p) (b_start:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma (requires B.length b_start = B.length b / 16 * 16 /\ b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\ Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b)) ) (ensures ( let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b))
false
false
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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", "smt.arith.nl=true" ], "z3refresh": false, "z3rlimit": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_slice_uv_extra (b b_start b_extra: uint8_p) (h: HS.mem) : Lemma (requires B.length b_start = (B.length b / 16) * 16 /\ b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\ Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b))) (ensures (let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b))))
[]
Vale.Wrapper.X64.GCMencryptOpt.lemma_slice_uv_extra
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> b_start: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> b_extra: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> h: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.length b_start = (LowStar.Monotonic.Buffer.length b / 16) * 16 /\ b_start == LowStar.Buffer.gsub b 0ul (FStar.UInt32.uint_to_t (LowStar.Monotonic.Buffer.length b_start)) /\ LowStar.Monotonic.Buffer.length b_extra = 16 /\ FStar.Seq.Base.equal (LowStar.Monotonic.Buffer.as_seq h b) (FStar.Seq.Base.slice (FStar.Seq.Base.append (LowStar.Monotonic.Buffer.as_seq h b_start) (LowStar.Monotonic.Buffer.as_seq h b_extra)) 0 (LowStar.Monotonic.Buffer.length b))) (ensures (let b_start_d = Vale.Interop.Types.get_downview b_start in [@@ FStar.Pervasives.inline_let ]let _ = Vale.Wrapper.X64.GCMencryptOpt.length_aux6 b_start in let b_start_u = LowStar.BufferView.Up.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = Vale.Interop.Types.get_downview b_extra in [@@ FStar.Pervasives.inline_let ]let _ = Vale.Wrapper.X64.GCMencryptOpt.length_aux6 b_extra in let b_extra_u = LowStar.BufferView.Up.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = FStar.Seq.Base.append (LowStar.BufferView.Up.as_seq h b_start_u) (LowStar.BufferView.Up.as_seq h b_extra_u) in let sf = Vale.Wrapper.X64.GCMencryptOpt.wrap_slice (Vale.Def.Types_s.le_seq_quad32_to_bytes suv) (LowStar.Monotonic.Buffer.length b) in FStar.Seq.Base.equal sf (Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8 (LowStar.Monotonic.Buffer.as_seq h b))))
{ "end_col": 4, "end_line": 831, "start_col": 2, "start_line": 785 }
FStar.Pervasives.Lemma
val lemma_slice_sub (b b_sub b_extra: uint8_p) (h: HS.mem) : Lemma (requires B.length b_extra = 16 /\ B.length b_sub = (B.length b / 16) * 16 /\ b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\ Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))) (ensures Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b)))
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_slice_sub (b:uint8_p) (b_sub:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma (requires B.length b_extra = 16 /\ B.length b_sub = B.length b / 16 * 16 /\ b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\ Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)) ) (ensures Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b)) ) = calc (==) { Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b); (==) { Seq.lemma_eq_intro (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b)) (Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))) } Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)); (==) { } Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)); (==) { } Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub)) (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b)); (==) { Seq.lemma_eq_intro (B.as_seq h b) (Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub)) (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b))) } B.as_seq h b; }
val lemma_slice_sub (b b_sub b_extra: uint8_p) (h: HS.mem) : Lemma (requires B.length b_extra = 16 /\ B.length b_sub = (B.length b / 16) * 16 /\ b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\ Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))) (ensures Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))) let lemma_slice_sub (b b_sub b_extra: uint8_p) (h: HS.mem) : Lemma (requires B.length b_extra = 16 /\ B.length b_sub = (B.length b / 16) * 16 /\ b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\ Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))) (ensures Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))) =
false
null
true
calc ( == ) { Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b); ( == ) { Seq.lemma_eq_intro (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b)) (Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))) } Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)); ( == ) { () } Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)); ( == ) { () } Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub)) (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b)); ( == ) { Seq.lemma_eq_intro (B.as_seq h b) (Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub)) (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b))) } B.as_seq h b; }
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "lemma" ]
[ "Vale.Wrapper.X64.GCMencryptOpt.uint8_p", "FStar.Monotonic.HyperStack.mem", "FStar.Calc.calc_finish", "FStar.Seq.Base.seq", "FStar.UInt8.t", "Prims.eq2", "FStar.Seq.Base.slice", "FStar.Seq.Base.append", "LowStar.Monotonic.Buffer.as_seq", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.length", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Integers.op_Percent", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Seq.Base.lemma_eq_intro", "Prims.squash", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Integers.op_Star", "FStar.Integers.op_Slash", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.gsub", "FStar.UInt32.__uint_to_t", "FStar.UInt32.uint_to_t", "FStar.Seq.Base.equal", "FStar.Integers.op_Plus", "FStar.Pervasives.pattern" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) #reset-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" let math_aux (n:nat) : Lemma (n * 1 == n) = () let length_div (b:uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) = DV.length_eq (get_downview b) inline_for_extraction val gcm128_encrypt_opt': key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> auth_b:uint8_p -> auth_bytes:uint64 -> auth_num:uint64 -> keys_b:uint8_p -> iv_b:uint8_p -> hkeys_b:uint8_p -> abytes_b:uint8_p -> in128x6_b:uint8_p -> out128x6_b:uint8_p -> len128x6:uint64 -> in128_b:uint8_p -> out128_b:uint8_p -> len128_num:uint64 -> inout_b:uint8_p -> plain_num:uint64 -> scratch_b:uint8_p -> tag_b:uint8_p -> Stack unit (requires fun h0 -> B.disjoint tag_b keys_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b abytes_b /\ B.disjoint tag_b iv_b /\ B.disjoint tag_b in128x6_b /\ B.disjoint tag_b out128x6_b /\ B.disjoint tag_b in128_b /\ B.disjoint tag_b out128_b /\ B.disjoint tag_b inout_b /\ B.disjoint tag_b scratch_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b auth_b /\ B.disjoint iv_b abytes_b /\ B.disjoint iv_b in128x6_b /\ B.disjoint iv_b out128x6_b /\ B.disjoint iv_b in128_b /\ B.disjoint iv_b out128_b /\ B.disjoint iv_b inout_b /\ B.disjoint iv_b scratch_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint scratch_b in128x6_b /\ B.disjoint scratch_b out128x6_b /\ B.disjoint scratch_b in128_b /\ B.disjoint scratch_b out128_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b abytes_b /\ B.disjoint inout_b in128x6_b /\ B.disjoint inout_b out128x6_b /\ B.disjoint inout_b in128_b /\ B.disjoint inout_b out128_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint out128x6_b keys_b /\ B.disjoint out128x6_b auth_b /\ B.disjoint out128x6_b abytes_b /\ B.disjoint out128x6_b hkeys_b /\ B.disjoint out128x6_b in128_b /\ B.disjoint out128x6_b inout_b /\ B.disjoint in128x6_b keys_b /\ B.disjoint in128x6_b auth_b /\ B.disjoint in128x6_b abytes_b /\ B.disjoint in128x6_b hkeys_b /\ B.disjoint in128x6_b in128_b /\ B.disjoint in128x6_b inout_b /\ B.disjoint out128_b keys_b /\ B.disjoint out128_b auth_b /\ B.disjoint out128_b abytes_b /\ B.disjoint out128_b hkeys_b /\ B.disjoint out128_b in128x6_b /\ B.disjoint out128_b out128x6_b /\ B.disjoint out128_b inout_b /\ B.disjoint in128_b keys_b /\ B.disjoint in128_b auth_b /\ B.disjoint in128_b abytes_b /\ B.disjoint in128_b hkeys_b /\ B.disjoint in128_b in128x6_b /\ B.disjoint in128_b out128x6_b /\ B.disjoint in128_b inout_b /\ B.disjoint keys_b abytes_b /\ B.disjoint hkeys_b auth_b /\ B.disjoint hkeys_b abytes_b /\ B.disjoint auth_b abytes_b /\ B.disjoint keys_b auth_b /\ disjoint_or_eq in128x6_b out128x6_b /\ disjoint_or_eq in128_b out128_b /\ disjoint_or_eq keys_b hkeys_b /\ B.live h0 auth_b /\ B.live h0 abytes_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 in128x6_b /\ B.live h0 out128x6_b /\ B.live h0 in128_b /\ B.live h0 out128_b /\ B.live h0 inout_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.length auth_b = 16 * UInt64.v auth_num /\ B.length abytes_b == 16 /\ B.length iv_b = 16 /\ B.length in128x6_b == 16 * UInt64.v len128x6 /\ B.length out128x6_b == B.length in128x6_b /\ B.length in128_b == 16 * UInt64.v len128_num /\ B.length out128_b == B.length in128_b /\ B.length inout_b == 16 /\ B.length scratch_b == 144 /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ UInt64.v plain_num < pow2_32 /\ UInt64.v auth_bytes < pow2_32 /\ UInt64.v len128x6 % 6 == 0 /\ (UInt64.v len128x6 > 0 ==> UInt64.v len128x6 >= 18) /\ 12 + UInt64.v len128x6 + 6 < pow2_32 /\ UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) <= UInt64.v plain_num /\ UInt64.v plain_num < UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) + 128/8 /\ UInt64.v auth_num * (128/8) <= UInt64.v auth_bytes /\ UInt64.v auth_bytes < UInt64.v auth_num * (128/8) + 128/8 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) /\ (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)))) /\ (length_div iv_b; (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out128x6_b) (B.loc_union (B.loc_buffer out128_b) (B.loc_buffer inout_b)))))) h0 h1 /\ ((UInt64.v plain_num) < pow2_32 /\ (UInt64.v auth_bytes) < pow2_32 /\ ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_num) in let cipher_out = Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_num) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_num); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_bytes) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ is_aes_key AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in cipher == cipher_bytes /\ (length_div tag_b; le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h1 tag_b 0) == tag )))) ) #push-options "--z3cliopt smt.arith.nl=true --retry 3 --z3rlimit 800 --ext compat:normalizer_memo_ignore_cfg" #restart-solver inline_for_extraction let gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b = let h0 = get() in B.disjoint_neq iv_b auth_b; B.disjoint_neq iv_b keys_b; B.disjoint_neq iv_b hkeys_b; B.disjoint_neq iv_b abytes_b; B.disjoint_neq iv_b in128x6_b; B.disjoint_neq iv_b out128x6_b; B.disjoint_neq iv_b in128_b; B.disjoint_neq iv_b out128_b; B.disjoint_neq iv_b inout_b; B.disjoint_neq iv_b scratch_b; B.disjoint_neq iv_b tag_b; DV.length_eq (get_downview auth_b); DV.length_eq (get_downview keys_b); DV.length_eq (get_downview iv_b); DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview abytes_b); DV.length_eq (get_downview in128x6_b); DV.length_eq (get_downview out128x6_b); DV.length_eq (get_downview in128_b); DV.length_eq (get_downview out128_b); DV.length_eq (get_downview inout_b); DV.length_eq (get_downview scratch_b); DV.length_eq (get_downview tag_b); math_aux (B.length auth_b); math_aux (B.length keys_b); math_aux (B.length iv_b); math_aux (B.length hkeys_b); math_aux (B.length in128x6_b); math_aux (B.length scratch_b); math_aux (B.length out128_b); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v auth_num) 16; assert_norm (176 % 16 = 0); assert_norm (16 % 16 = 0); assert_norm (144 % 16 = 0); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128x6) 16; FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128_num) 16; calc (<=) { 256 * ((16 * UInt64.v len128_num) / 16); (==) { FStar.Math.Lemmas.cancel_mul_div (UInt64.v len128_num) 16 } 256 * (UInt64.v len128_num); ( <= ) { assert_norm (256 <= 4096); FStar.Math.Lemmas.lemma_mult_le_right (UInt64.v len128_num) 256 4096 } 4096 * (UInt64.v len128_num); }; assert (DV.length (get_downview tag_b) % 16 = 0); assert (DV.length (get_downview scratch_b) % 16 = 0); assert (DV.length (get_downview out128_b) % 16 = 0); as_vale_buffer_len #TUInt8 #TUInt128 auth_b; as_vale_buffer_len #TUInt8 #TUInt128 keys_b; as_vale_buffer_len #TUInt8 #TUInt128 iv_b; as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b; as_vale_buffer_len #TUInt8 #TUInt128 abytes_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128_b; as_vale_buffer_len #TUInt8 #TUInt128 inout_b; as_vale_buffer_len #TUInt8 #TUInt128 scratch_b; as_vale_buffer_len #TUInt8 #TUInt128 tag_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 auth_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 inout_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 keys_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b; let (x, _) = gcm128_encrypt_opt key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b () in let h1 = get() in () #pop-options inline_for_extraction val gcm128_encrypt_opt_alloca: key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> plain_b:uint8_p -> plain_len:uint64 -> auth_b:uint8_p -> auth_len:uint64 -> iv_b:uint8_p -> out_b:uint8_p -> tag_b:uint8_p -> keys_b:uint8_p -> hkeys_b:uint8_p -> scratch_b:uint8_p -> inout_b : uint8_p -> abytes_b : uint8_p -> Stack unit (requires fun h0 -> B.disjoint scratch_b tag_b /\ B.disjoint scratch_b out_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint scratch_b plain_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b iv_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint inout_b tag_b /\ B.disjoint inout_b out_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint inout_b plain_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b iv_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b abytes_b /\ B.disjoint abytes_b tag_b /\ B.disjoint abytes_b out_b /\ B.disjoint abytes_b hkeys_b /\ B.disjoint abytes_b plain_b /\ B.disjoint abytes_b auth_b /\ B.disjoint abytes_b iv_b /\ B.disjoint abytes_b keys_b /\ B.disjoint tag_b out_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint tag_b plain_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b iv_b /\ disjoint_or_eq tag_b keys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b out_b /\ B.disjoint iv_b plain_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint iv_b auth_b /\ B.disjoint out_b keys_b /\ B.disjoint out_b hkeys_b /\ B.disjoint out_b auth_b /\ disjoint_or_eq out_b plain_b /\ B.disjoint plain_b keys_b /\ B.disjoint plain_b hkeys_b /\ B.disjoint plain_b auth_b /\ disjoint_or_eq keys_b hkeys_b /\ B.disjoint keys_b auth_b /\ B.disjoint hkeys_b auth_b /\ B.live h0 auth_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 out_b /\ B.live h0 plain_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.live h0 inout_b /\ B.live h0 abytes_b /\ B.length auth_b = (UInt64.v auth_len / 16) * 16 /\ B.length iv_b = 16 /\ B.length plain_b = (UInt64.v plain_len / 16) * 16 /\ B.length out_b = B.length plain_b /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ B.length scratch_b = 144 /\ B.length inout_b = 16 /\ B.length abytes_b = 16 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (Seq.equal (B.as_seq h0 keys_b) (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key))))) /\ hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0))) /\ (le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out_b) (B.loc_buffer inout_b))))) h0 h1 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ (let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in Seq.length plain_bytes < pow2_32 /\ Seq.length auth_bytes < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h1 tag_b)) tag ) )) let lemma_same_seq_dv (h:HS.mem) (b:uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) = let db = get_downview b in DV.length_eq db; let aux (i:nat{i < B.length b}) : Lemma (Seq.index (B.as_seq h b) i == Seq.index (DV.as_seq h db) i) = DV.as_seq_sel h db i; DV.get_sel h db i; Vale.Interop.Views.put8_reveal () in Classical.forall_intro aux let lemma_uv_split (h:HS.mem) (b:uint8_p) (n:UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures ( let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs) ) = let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in calc (==) { Seq.length split_bs; (==) { } Seq.length (UV.as_seq h b1_u) + Seq.length (UV.as_seq h b2_u); (==) { UV.length_eq b1_u; UV.length_eq b2_u } DV.length b1_d / 16 + DV.length b2_d / 16; (==) { DV.length_eq b1_d; DV.length_eq b2_d; math_aux (B.length b1); math_aux (B.length b2) } B.length b1 / 16 + B.length b2 / 16; (==) { } B.length b / 16; (==) { DV.length_eq b_d; UV.length_eq b_u; math_aux (B.length b) } Seq.length bs; }; assert (Seq.length bs == Seq.length split_bs); let aux (i:nat{ i < Seq.length bs}) : Lemma (Seq.index bs i = Seq.index split_bs i) = UV.length_eq b_u; lemma_same_seq_dv h b; calc (==) { Seq.index bs i; (==) { UV.as_seq_sel h b_u i } UV.sel h b_u i; (==) { UV.get_sel h b_u i } Vale.Interop.Views.get128 (Seq.slice (DV.as_seq h b_d) (i * 16) (i * 16 + 16)); (==) { lemma_same_seq_dv h b } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b) (i * 16) (i * 16 + 16)); (==) { assert (Seq.equal (B.as_seq h b) (Seq.append (B.as_seq h b1) (B.as_seq h b2))) } Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); }; if i < Seq.length (UV.as_seq h b1_u) then ( lemma_same_seq_dv h b1; UV.length_eq b1_u; calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b1) (i * 16) (i * 16 + 16)); (==) { UV.get_sel h b1_u i } UV.sel h b1_u i; (==) { UV.as_seq_sel h b1_u i } Seq.index (UV.as_seq h b1_u) i; (==) { } Seq.index split_bs i; } ) else ( lemma_same_seq_dv h b2; UV.length_eq b2_u; let j = i - UV.length b1_u in calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b2) (j * 16) (j * 16 + 16)); (==) { UV.get_sel h b2_u j } UV.sel h b2_u j; (==) { UV.as_seq_sel h b2_u j } Seq.index (UV.as_seq h b2_u) j; (==) { } Seq.index split_bs i; } ) in Classical.forall_intro aux let math_cast_aux (n:UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n) = FStar.Math.Lemmas.small_mod (UInt64.v n) (pow2 32) inline_for_extraction let gcm128_encrypt_opt_alloca key iv plain_b plain_len auth_b auth_bytes iv_b out_b tag_b keys_b hkeys_b scratch_b inout_b abytes_b = let h0 = get() in let lemma_uv_key () : Lemma (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) = length_aux keys_b; let db = get_downview keys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in le_bytes_to_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key)); assert (Seq.equal (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b))) (key_to_round_keys_LE AES_128 (Ghost.reveal key))); calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 keys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_key (); // Simplify the precondition for hkeys_b let lemma_uv_hkey () : Lemma (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in UV.as_seq h0 ub == le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) = length_aux5 hkeys_b; let db = get_downview hkeys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 hkeys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_hkey (); // Simplify the expression for the iv DV.length_eq (get_downview iv_b); length_aux4 iv_b; calc (==) { compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv); (==) { } le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b)); (==) { gcm_simplify2 iv_b h0 } le_bytes_to_quad32 (le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0)); (==) { le_bytes_to_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) } low_buffer_read TUInt8 TUInt128 h0 iv_b 0; }; // Compute length of biggest blocks of 6 * 128-bit blocks let len128x6 = UInt64.mul (plain_len / 96uL) 96uL in if len128x6 / 16uL >= 18uL then ( let len128_num = ((plain_len / 16uL) * 16uL) - len128x6 in // Casting to uint32 is here the equality math_cast_aux len128x6; math_cast_aux len128_num; let in128x6_b = B.sub plain_b 0ul (uint64_to_uint32 len128x6) in let out128x6_b = B.sub out_b 0ul (uint64_to_uint32 len128x6) in let in128_b = B.sub plain_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128x6' = UInt64.div len128x6 16uL in let len128_num' = UInt64.div len128_num 16uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b (uint64_to_uint32 len128x6); // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b (uint64_to_uint32 len128x6); assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ) else ( let len128x6 = 0ul in // Compute the size of the remaining 128-bit blocks let len128_num = ((plain_len / 16uL) * 16uL) in // Casting to uint32 is here the equality FStar.Math.Lemmas.small_mod (UInt64.v len128_num) pow2_32; let in128x6_b = B.sub plain_b 0ul len128x6 in let out128x6_b = B.sub out_b 0ul len128x6 in let in128_b = B.sub plain_b len128x6 (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b len128x6 (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128_num' = UInt64.div len128_num 16uL in let len128x6' = 0uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b len128x6; // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b len128x6; assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ); // Simplify post condition for tag let h_f = get() in gcm_simplify2 tag_b h_f let lemma_identical_uv (b:uint8_p) (h0 h1:HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures ( let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 b_u) (UV.as_seq h1 b_u))) = lemma_dv_equal Vale.Interop.Views.down_view8 b h0 h1; length_aux3 b (B.length b / 16); lemma_uv_equal Vale.Interop.Views.up_view128 (get_downview b) h0 h1 let length_aux6 (b:uint8_p) : Lemma (B.length b = DV.length (get_downview b)) = DV.length_eq (get_downview b) #push-options "--z3cliopt smt.arith.nl=true" let lemma_slice_uv_extra (b:uint8_p) (b_start:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma (requires B.length b_start = B.length b / 16 * 16 /\ b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\ Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b)) ) (ensures ( let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b)) )) = let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in let b_f = seq_uint8_to_seq_nat8 (B.as_seq h b) in // if B.length b > B.length b_start then ( calc (==) { sf; (==) { DV.length_eq b_start_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_start h; le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_start_u) } wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (UV.as_seq h b_extra_u))) (B.length b); (==) { DV.length_eq b_extra_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_extra h; le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_extra_u) } wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))))) (B.length b); (==) { append_distributes_le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) } wrap_slice (Seq.append (le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))) (le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))))) (B.length b); (==) { le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)); le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)) } wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start)) (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) (B.length b); (==) { Seq.lemma_eq_intro b_f (wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start)) (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) (B.length b)) } b_f; } // ) else ( // calc (==) { // sf; // (==) { } // wrap_slice (le_seq_quad32_to_bytes (UV.as_seq h b_start_u)) (B.length b); // (==) { DV.length_eq (get_downview b_start); // gcm_simplify1 b_start h (B.length b) } // seq_uint8_to_seq_nat8 (B.as_seq h b_start); // (==) { } // b_f; // } // ) #pop-options let lemma_slice_sub (b:uint8_p) (b_sub:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma (requires B.length b_extra = 16 /\ B.length b_sub = B.length b / 16 * 16 /\ b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\ Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)) ) (ensures Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b))
false
false
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_slice_sub (b b_sub b_extra: uint8_p) (h: HS.mem) : Lemma (requires B.length b_extra = 16 /\ B.length b_sub = (B.length b / 16) * 16 /\ b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\ Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))) (ensures Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b)))
[]
Vale.Wrapper.X64.GCMencryptOpt.lemma_slice_sub
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> b_sub: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> b_extra: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> h: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.length b_extra = 16 /\ LowStar.Monotonic.Buffer.length b_sub = (LowStar.Monotonic.Buffer.length b / 16) * 16 /\ b_sub == LowStar.Buffer.gsub b 0ul (FStar.UInt32.uint_to_t (LowStar.Monotonic.Buffer.length b_sub)) /\ FStar.Seq.Base.equal (FStar.Seq.Base.slice (LowStar.Monotonic.Buffer.as_seq h b) (LowStar.Monotonic.Buffer.length b_sub) (LowStar.Monotonic.Buffer.length b_sub + LowStar.Monotonic.Buffer.length b % 16)) (FStar.Seq.Base.slice (LowStar.Monotonic.Buffer.as_seq h b_extra) 0 (LowStar.Monotonic.Buffer.length b % 16))) (ensures FStar.Seq.Base.equal (LowStar.Monotonic.Buffer.as_seq h b) (FStar.Seq.Base.slice (FStar.Seq.Base.append (LowStar.Monotonic.Buffer.as_seq h b_sub) (LowStar.Monotonic.Buffer.as_seq h b_extra)) 0 (LowStar.Monotonic.Buffer.length b)))
{ "end_col": 3, "end_line": 878, "start_col": 2, "start_line": 857 }
FStar.Pervasives.Lemma
val lemma_uv_split (h: HS.mem) (b: uint8_p) (n: UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures (let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs))
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_uv_split (h:HS.mem) (b:uint8_p) (n:UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures ( let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs) ) = let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in calc (==) { Seq.length split_bs; (==) { } Seq.length (UV.as_seq h b1_u) + Seq.length (UV.as_seq h b2_u); (==) { UV.length_eq b1_u; UV.length_eq b2_u } DV.length b1_d / 16 + DV.length b2_d / 16; (==) { DV.length_eq b1_d; DV.length_eq b2_d; math_aux (B.length b1); math_aux (B.length b2) } B.length b1 / 16 + B.length b2 / 16; (==) { } B.length b / 16; (==) { DV.length_eq b_d; UV.length_eq b_u; math_aux (B.length b) } Seq.length bs; }; assert (Seq.length bs == Seq.length split_bs); let aux (i:nat{ i < Seq.length bs}) : Lemma (Seq.index bs i = Seq.index split_bs i) = UV.length_eq b_u; lemma_same_seq_dv h b; calc (==) { Seq.index bs i; (==) { UV.as_seq_sel h b_u i } UV.sel h b_u i; (==) { UV.get_sel h b_u i } Vale.Interop.Views.get128 (Seq.slice (DV.as_seq h b_d) (i * 16) (i * 16 + 16)); (==) { lemma_same_seq_dv h b } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b) (i * 16) (i * 16 + 16)); (==) { assert (Seq.equal (B.as_seq h b) (Seq.append (B.as_seq h b1) (B.as_seq h b2))) } Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); }; if i < Seq.length (UV.as_seq h b1_u) then ( lemma_same_seq_dv h b1; UV.length_eq b1_u; calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b1) (i * 16) (i * 16 + 16)); (==) { UV.get_sel h b1_u i } UV.sel h b1_u i; (==) { UV.as_seq_sel h b1_u i } Seq.index (UV.as_seq h b1_u) i; (==) { } Seq.index split_bs i; } ) else ( lemma_same_seq_dv h b2; UV.length_eq b2_u; let j = i - UV.length b1_u in calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b2) (j * 16) (j * 16 + 16)); (==) { UV.get_sel h b2_u j } UV.sel h b2_u j; (==) { UV.as_seq_sel h b2_u j } Seq.index (UV.as_seq h b2_u) j; (==) { } Seq.index split_bs i; } ) in Classical.forall_intro aux
val lemma_uv_split (h: HS.mem) (b: uint8_p) (n: UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures (let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs)) let lemma_uv_split (h: HS.mem) (b: uint8_p) (n: UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures (let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs)) =
false
null
true
let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in calc ( == ) { Seq.length split_bs; ( == ) { () } Seq.length (UV.as_seq h b1_u) + Seq.length (UV.as_seq h b2_u); ( == ) { (UV.length_eq b1_u; UV.length_eq b2_u) } DV.length b1_d / 16 + DV.length b2_d / 16; ( == ) { (DV.length_eq b1_d; DV.length_eq b2_d; math_aux (B.length b1); math_aux (B.length b2)) } B.length b1 / 16 + B.length b2 / 16; ( == ) { () } B.length b / 16; ( == ) { (DV.length_eq b_d; UV.length_eq b_u; math_aux (B.length b)) } Seq.length bs; }; assert (Seq.length bs == Seq.length split_bs); let aux (i: nat{i < Seq.length bs}) : Lemma (Seq.index bs i = Seq.index split_bs i) = UV.length_eq b_u; lemma_same_seq_dv h b; calc ( == ) { Seq.index bs i; ( == ) { UV.as_seq_sel h b_u i } UV.sel h b_u i; ( == ) { UV.get_sel h b_u i } Vale.Interop.Views.get128 (Seq.slice (DV.as_seq h b_d) (i * 16) (i * 16 + 16)); ( == ) { lemma_same_seq_dv h b } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b) (i * 16) (i * 16 + 16)); ( == ) { assert (Seq.equal (B.as_seq h b) (Seq.append (B.as_seq h b1) (B.as_seq h b2))) } Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); }; if i < Seq.length (UV.as_seq h b1_u) then (lemma_same_seq_dv h b1; UV.length_eq b1_u; calc ( == ) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); ( == ) { () } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b1) (i * 16) (i * 16 + 16)); ( == ) { UV.get_sel h b1_u i } UV.sel h b1_u i; ( == ) { UV.as_seq_sel h b1_u i } Seq.index (UV.as_seq h b1_u) i; ( == ) { () } Seq.index split_bs i; }) else (lemma_same_seq_dv h b2; UV.length_eq b2_u; let j = i - UV.length b1_u in calc ( == ) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); ( == ) { () } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b2) (j * 16) (j * 16 + 16)); ( == ) { UV.get_sel h b2_u j } UV.sel h b2_u j; ( == ) { UV.as_seq_sel h b2_u j } Seq.index (UV.as_seq h b2_u) j; ( == ) { () } Seq.index split_bs i; }) in Classical.forall_intro aux
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "lemma" ]
[ "FStar.Monotonic.HyperStack.mem", "Vale.Wrapper.X64.GCMencryptOpt.uint8_p", "FStar.UInt32.t", "FStar.Classical.forall_intro", "FStar.Integers.nat", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Seq.Base.length", "Vale.Def.Types_s.quad32", "Prims.op_Equality", "FStar.Seq.Base.index", "FStar.Integers.int_t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "LowStar.BufferView.Up.as_seq", "FStar.Calc.calc_finish", "Prims.eq2", "Vale.Interop.Views.get128", "FStar.Seq.Base.slice", "FStar.UInt8.t", "FStar.Seq.Base.append", "LowStar.Monotonic.Buffer.as_seq", "LowStar.Buffer.trivial_preorder", "FStar.Integers.op_Star", "FStar.Integers.op_Plus", "Prims.Cons", "FStar.Preorder.relation", "FStar.Calc.calc_step", "LowStar.BufferView.Up.sel", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "LowStar.BufferView.Up.get_sel", "LowStar.BufferView.Up.as_seq_sel", "LowStar.BufferView.Up.length_eq", "Vale.Wrapper.X64.GCMencryptOpt.lemma_same_seq_dv", "Prims.bool", "FStar.Integers.op_Subtraction", "LowStar.BufferView.Up.length", "LowStar.BufferView.Down.as_seq", "Prims._assert", "FStar.Seq.Base.equal", "Prims.nat", "FStar.Integers.op_Slash", "LowStar.Monotonic.Buffer.length", "LowStar.BufferView.Down.length", "Vale.Wrapper.X64.GCMencryptOpt.math_aux", "LowStar.BufferView.Down.length_eq", "FStar.Seq.Properties.lseq", "FStar.Seq.Base.seq", "LowStar.BufferView.Up.buffer", "LowStar.BufferView.Up.mk_buffer", "Vale.Interop.Views.up_view128", "Vale.Wrapper.X64.GCMencryptOpt.length_aux3", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Arch.HeapTypes_s.TUInt8", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.gsub", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.UInt32.uint_to_t", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Prims.int", "FStar.Integers.op_Percent", "FStar.UInt32.v", "FStar.Integers.op_Less_Equals" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) #reset-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" let math_aux (n:nat) : Lemma (n * 1 == n) = () let length_div (b:uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) = DV.length_eq (get_downview b) inline_for_extraction val gcm128_encrypt_opt': key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> auth_b:uint8_p -> auth_bytes:uint64 -> auth_num:uint64 -> keys_b:uint8_p -> iv_b:uint8_p -> hkeys_b:uint8_p -> abytes_b:uint8_p -> in128x6_b:uint8_p -> out128x6_b:uint8_p -> len128x6:uint64 -> in128_b:uint8_p -> out128_b:uint8_p -> len128_num:uint64 -> inout_b:uint8_p -> plain_num:uint64 -> scratch_b:uint8_p -> tag_b:uint8_p -> Stack unit (requires fun h0 -> B.disjoint tag_b keys_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b abytes_b /\ B.disjoint tag_b iv_b /\ B.disjoint tag_b in128x6_b /\ B.disjoint tag_b out128x6_b /\ B.disjoint tag_b in128_b /\ B.disjoint tag_b out128_b /\ B.disjoint tag_b inout_b /\ B.disjoint tag_b scratch_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b auth_b /\ B.disjoint iv_b abytes_b /\ B.disjoint iv_b in128x6_b /\ B.disjoint iv_b out128x6_b /\ B.disjoint iv_b in128_b /\ B.disjoint iv_b out128_b /\ B.disjoint iv_b inout_b /\ B.disjoint iv_b scratch_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint scratch_b in128x6_b /\ B.disjoint scratch_b out128x6_b /\ B.disjoint scratch_b in128_b /\ B.disjoint scratch_b out128_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b abytes_b /\ B.disjoint inout_b in128x6_b /\ B.disjoint inout_b out128x6_b /\ B.disjoint inout_b in128_b /\ B.disjoint inout_b out128_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint out128x6_b keys_b /\ B.disjoint out128x6_b auth_b /\ B.disjoint out128x6_b abytes_b /\ B.disjoint out128x6_b hkeys_b /\ B.disjoint out128x6_b in128_b /\ B.disjoint out128x6_b inout_b /\ B.disjoint in128x6_b keys_b /\ B.disjoint in128x6_b auth_b /\ B.disjoint in128x6_b abytes_b /\ B.disjoint in128x6_b hkeys_b /\ B.disjoint in128x6_b in128_b /\ B.disjoint in128x6_b inout_b /\ B.disjoint out128_b keys_b /\ B.disjoint out128_b auth_b /\ B.disjoint out128_b abytes_b /\ B.disjoint out128_b hkeys_b /\ B.disjoint out128_b in128x6_b /\ B.disjoint out128_b out128x6_b /\ B.disjoint out128_b inout_b /\ B.disjoint in128_b keys_b /\ B.disjoint in128_b auth_b /\ B.disjoint in128_b abytes_b /\ B.disjoint in128_b hkeys_b /\ B.disjoint in128_b in128x6_b /\ B.disjoint in128_b out128x6_b /\ B.disjoint in128_b inout_b /\ B.disjoint keys_b abytes_b /\ B.disjoint hkeys_b auth_b /\ B.disjoint hkeys_b abytes_b /\ B.disjoint auth_b abytes_b /\ B.disjoint keys_b auth_b /\ disjoint_or_eq in128x6_b out128x6_b /\ disjoint_or_eq in128_b out128_b /\ disjoint_or_eq keys_b hkeys_b /\ B.live h0 auth_b /\ B.live h0 abytes_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 in128x6_b /\ B.live h0 out128x6_b /\ B.live h0 in128_b /\ B.live h0 out128_b /\ B.live h0 inout_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.length auth_b = 16 * UInt64.v auth_num /\ B.length abytes_b == 16 /\ B.length iv_b = 16 /\ B.length in128x6_b == 16 * UInt64.v len128x6 /\ B.length out128x6_b == B.length in128x6_b /\ B.length in128_b == 16 * UInt64.v len128_num /\ B.length out128_b == B.length in128_b /\ B.length inout_b == 16 /\ B.length scratch_b == 144 /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ UInt64.v plain_num < pow2_32 /\ UInt64.v auth_bytes < pow2_32 /\ UInt64.v len128x6 % 6 == 0 /\ (UInt64.v len128x6 > 0 ==> UInt64.v len128x6 >= 18) /\ 12 + UInt64.v len128x6 + 6 < pow2_32 /\ UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) <= UInt64.v plain_num /\ UInt64.v plain_num < UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) + 128/8 /\ UInt64.v auth_num * (128/8) <= UInt64.v auth_bytes /\ UInt64.v auth_bytes < UInt64.v auth_num * (128/8) + 128/8 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) /\ (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)))) /\ (length_div iv_b; (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out128x6_b) (B.loc_union (B.loc_buffer out128_b) (B.loc_buffer inout_b)))))) h0 h1 /\ ((UInt64.v plain_num) < pow2_32 /\ (UInt64.v auth_bytes) < pow2_32 /\ ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_num) in let cipher_out = Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_num) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_num); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_bytes) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ is_aes_key AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in cipher == cipher_bytes /\ (length_div tag_b; le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h1 tag_b 0) == tag )))) ) #push-options "--z3cliopt smt.arith.nl=true --retry 3 --z3rlimit 800 --ext compat:normalizer_memo_ignore_cfg" #restart-solver inline_for_extraction let gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b = let h0 = get() in B.disjoint_neq iv_b auth_b; B.disjoint_neq iv_b keys_b; B.disjoint_neq iv_b hkeys_b; B.disjoint_neq iv_b abytes_b; B.disjoint_neq iv_b in128x6_b; B.disjoint_neq iv_b out128x6_b; B.disjoint_neq iv_b in128_b; B.disjoint_neq iv_b out128_b; B.disjoint_neq iv_b inout_b; B.disjoint_neq iv_b scratch_b; B.disjoint_neq iv_b tag_b; DV.length_eq (get_downview auth_b); DV.length_eq (get_downview keys_b); DV.length_eq (get_downview iv_b); DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview abytes_b); DV.length_eq (get_downview in128x6_b); DV.length_eq (get_downview out128x6_b); DV.length_eq (get_downview in128_b); DV.length_eq (get_downview out128_b); DV.length_eq (get_downview inout_b); DV.length_eq (get_downview scratch_b); DV.length_eq (get_downview tag_b); math_aux (B.length auth_b); math_aux (B.length keys_b); math_aux (B.length iv_b); math_aux (B.length hkeys_b); math_aux (B.length in128x6_b); math_aux (B.length scratch_b); math_aux (B.length out128_b); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v auth_num) 16; assert_norm (176 % 16 = 0); assert_norm (16 % 16 = 0); assert_norm (144 % 16 = 0); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128x6) 16; FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128_num) 16; calc (<=) { 256 * ((16 * UInt64.v len128_num) / 16); (==) { FStar.Math.Lemmas.cancel_mul_div (UInt64.v len128_num) 16 } 256 * (UInt64.v len128_num); ( <= ) { assert_norm (256 <= 4096); FStar.Math.Lemmas.lemma_mult_le_right (UInt64.v len128_num) 256 4096 } 4096 * (UInt64.v len128_num); }; assert (DV.length (get_downview tag_b) % 16 = 0); assert (DV.length (get_downview scratch_b) % 16 = 0); assert (DV.length (get_downview out128_b) % 16 = 0); as_vale_buffer_len #TUInt8 #TUInt128 auth_b; as_vale_buffer_len #TUInt8 #TUInt128 keys_b; as_vale_buffer_len #TUInt8 #TUInt128 iv_b; as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b; as_vale_buffer_len #TUInt8 #TUInt128 abytes_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128_b; as_vale_buffer_len #TUInt8 #TUInt128 inout_b; as_vale_buffer_len #TUInt8 #TUInt128 scratch_b; as_vale_buffer_len #TUInt8 #TUInt128 tag_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 auth_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 inout_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 keys_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b; let (x, _) = gcm128_encrypt_opt key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b () in let h1 = get() in () #pop-options inline_for_extraction val gcm128_encrypt_opt_alloca: key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> plain_b:uint8_p -> plain_len:uint64 -> auth_b:uint8_p -> auth_len:uint64 -> iv_b:uint8_p -> out_b:uint8_p -> tag_b:uint8_p -> keys_b:uint8_p -> hkeys_b:uint8_p -> scratch_b:uint8_p -> inout_b : uint8_p -> abytes_b : uint8_p -> Stack unit (requires fun h0 -> B.disjoint scratch_b tag_b /\ B.disjoint scratch_b out_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint scratch_b plain_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b iv_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint inout_b tag_b /\ B.disjoint inout_b out_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint inout_b plain_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b iv_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b abytes_b /\ B.disjoint abytes_b tag_b /\ B.disjoint abytes_b out_b /\ B.disjoint abytes_b hkeys_b /\ B.disjoint abytes_b plain_b /\ B.disjoint abytes_b auth_b /\ B.disjoint abytes_b iv_b /\ B.disjoint abytes_b keys_b /\ B.disjoint tag_b out_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint tag_b plain_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b iv_b /\ disjoint_or_eq tag_b keys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b out_b /\ B.disjoint iv_b plain_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint iv_b auth_b /\ B.disjoint out_b keys_b /\ B.disjoint out_b hkeys_b /\ B.disjoint out_b auth_b /\ disjoint_or_eq out_b plain_b /\ B.disjoint plain_b keys_b /\ B.disjoint plain_b hkeys_b /\ B.disjoint plain_b auth_b /\ disjoint_or_eq keys_b hkeys_b /\ B.disjoint keys_b auth_b /\ B.disjoint hkeys_b auth_b /\ B.live h0 auth_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 out_b /\ B.live h0 plain_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.live h0 inout_b /\ B.live h0 abytes_b /\ B.length auth_b = (UInt64.v auth_len / 16) * 16 /\ B.length iv_b = 16 /\ B.length plain_b = (UInt64.v plain_len / 16) * 16 /\ B.length out_b = B.length plain_b /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ B.length scratch_b = 144 /\ B.length inout_b = 16 /\ B.length abytes_b = 16 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (Seq.equal (B.as_seq h0 keys_b) (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key))))) /\ hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0))) /\ (le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out_b) (B.loc_buffer inout_b))))) h0 h1 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ (let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in Seq.length plain_bytes < pow2_32 /\ Seq.length auth_bytes < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h1 tag_b)) tag ) )) let lemma_same_seq_dv (h:HS.mem) (b:uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) = let db = get_downview b in DV.length_eq db; let aux (i:nat{i < B.length b}) : Lemma (Seq.index (B.as_seq h b) i == Seq.index (DV.as_seq h db) i) = DV.as_seq_sel h db i; DV.get_sel h db i; Vale.Interop.Views.put8_reveal () in Classical.forall_intro aux let lemma_uv_split (h:HS.mem) (b:uint8_p) (n:UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures ( let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in
false
false
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_uv_split (h: HS.mem) (b: uint8_p) (n: UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures (let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs))
[]
Vale.Wrapper.X64.GCMencryptOpt.lemma_uv_split
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> b: Vale.Wrapper.X64.GCMencryptOpt.uint8_p -> n: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.length b % 16 = 0 /\ FStar.UInt32.v n % 16 = 0 /\ FStar.UInt32.v n <= LowStar.Monotonic.Buffer.length b) (ensures (let b1 = LowStar.Buffer.gsub b 0ul n in let b2 = LowStar.Buffer.gsub b n (FStar.UInt32.uint_to_t (LowStar.Monotonic.Buffer.length b) - n) in let b1_d = Vale.Interop.Types.get_downview b1 in [@@ FStar.Pervasives.inline_let ]let _ = Vale.Wrapper.X64.GCMencryptOpt.length_aux3 b1 (LowStar.Monotonic.Buffer.length b1 / 16) in let b1_u = LowStar.BufferView.Up.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = Vale.Interop.Types.get_downview b2 in [@@ FStar.Pervasives.inline_let ]let _ = Vale.Wrapper.X64.GCMencryptOpt.length_aux3 b2 (LowStar.Monotonic.Buffer.length b2 / 16) in let b2_u = LowStar.BufferView.Up.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = Vale.Interop.Types.get_downview b in [@@ FStar.Pervasives.inline_let ]let _ = Vale.Wrapper.X64.GCMencryptOpt.length_aux3 b (LowStar.Monotonic.Buffer.length b / 16) in let b_u = LowStar.BufferView.Up.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = FStar.Seq.Base.append (LowStar.BufferView.Up.as_seq h b1_u) (LowStar.BufferView.Up.as_seq h b2_u) in let bs = LowStar.BufferView.Up.as_seq h b_u in FStar.Seq.Base.equal bs split_bs))
{ "end_col": 33, "end_line": 517, "start_col": 5, "start_line": 444 }
Prims.Tot
val gcm128_encrypt_opt_stdcall: encrypt_opt_stdcall_st AES_128
[ { "abbrev": false, "full_module": "Vale.Lib.BufferViewHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Gcm_simplify", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.Simplify_Sha", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Wrapper.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm128_encrypt_opt_stdcall key iv plain_b plain_len auth_b auth_len iv_b out_b tag_b keys_b hkeys_b scratch_b = let h0 = get() in push_frame(); // Extra space to have a full input/output with length % 16 = 0 let inout_b = B.sub scratch_b 0ul 16ul in // Same for auth_b let abytes_b = B.sub scratch_b 16ul 16ul in // Scratch space for Vale procedure let scratch_b = B.sub scratch_b 32ul 144ul in // Copy the remainder of plain_b into inout_b math_cast_aux plain_len; math_cast_aux auth_len; let plain_len' = (uint64_to_uint32 plain_len / 16ul) * 16ul in let auth_len' = (uint64_to_uint32 auth_len / 16ul) * 16ul in let plain_b' = B.sub plain_b 0ul plain_len' in let out_b' = B.sub out_b 0ul plain_len' in let auth_b' = B.sub auth_b 0ul auth_len' in B.blit plain_b plain_len' inout_b 0ul (uint64_to_uint32 plain_len % 16ul); let h1 = get() in // Same with auth_b and abytes_b B.blit auth_b auth_len' abytes_b 0ul (uint64_to_uint32 auth_len % 16ul); let h1 = get() in gcm128_encrypt_opt_alloca key iv plain_b' plain_len auth_b' auth_len iv_b out_b' tag_b keys_b hkeys_b scratch_b inout_b abytes_b; let h_post = get() in // Copy back the remainder in inout_b into out_b B.blit inout_b 0ul out_b ((uint64_to_uint32 plain_len / 16ul) * 16ul) (uint64_to_uint32 plain_len % 16ul); let h2 = get() in assert ( let plain_d = get_downview plain_b' in length_aux3 plain_b' (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b' in length_aux3 out_b' (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h1 plain_u) (UV.as_seq h1 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h_post out_u) (UV.as_seq h_post inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b' in length_aux3 auth_b' (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h1 auth_u) (UV.as_seq h1 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h_post tag_b)) tag )); lemma_identical_uv out_b' h_post h2; lemma_identical_uv inout_b h_post h2; assert ( let out_d = get_downview out_b' in length_aux3 out_b' (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in UV.as_seq h_post out_u == UV.as_seq h2 out_u); assert ( let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in UV.as_seq h_post inout_u == UV.as_seq h2 inout_u); lemma_slice_sub plain_b plain_b' inout_b h1; lemma_slice_uv_extra plain_b plain_b' inout_b h1; lemma_slice_sub auth_b auth_b' abytes_b h1; lemma_slice_sub out_b out_b' inout_b h2; lemma_slice_uv_extra auth_b auth_b' abytes_b h1; lemma_slice_uv_extra out_b out_b' inout_b h2; assert ( let plain = seq_uint8_to_seq_nat8 (B.as_seq h1 plain_b) in let auth = seq_uint8_to_seq_nat8 (B.as_seq h1 auth_b) in let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain auth in Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h2 out_b)) cipher /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h2 tag_b)) tag); pop_frame()
val gcm128_encrypt_opt_stdcall: encrypt_opt_stdcall_st AES_128 let gcm128_encrypt_opt_stdcall key iv plain_b plain_len auth_b auth_len iv_b out_b tag_b keys_b hkeys_b scratch_b =
false
null
false
let h0 = get () in push_frame (); let inout_b = B.sub scratch_b 0ul 16ul in let abytes_b = B.sub scratch_b 16ul 16ul in let scratch_b = B.sub scratch_b 32ul 144ul in math_cast_aux plain_len; math_cast_aux auth_len; let plain_len' = (uint64_to_uint32 plain_len / 16ul) * 16ul in let auth_len' = (uint64_to_uint32 auth_len / 16ul) * 16ul in let plain_b' = B.sub plain_b 0ul plain_len' in let out_b' = B.sub out_b 0ul plain_len' in let auth_b' = B.sub auth_b 0ul auth_len' in B.blit plain_b plain_len' inout_b 0ul (uint64_to_uint32 plain_len % 16ul); let h1 = get () in B.blit auth_b auth_len' abytes_b 0ul (uint64_to_uint32 auth_len % 16ul); let h1 = get () in gcm128_encrypt_opt_alloca key iv plain_b' plain_len auth_b' auth_len iv_b out_b' tag_b keys_b hkeys_b scratch_b inout_b abytes_b; let h_post = get () in B.blit inout_b 0ul out_b ((uint64_to_uint32 plain_len / 16ul) * 16ul) (uint64_to_uint32 plain_len % 16ul); let h2 = get () in assert (let plain_d = get_downview plain_b' in length_aux3 plain_b' (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b' in length_aux3 out_b' (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h1 plain_u) (UV.as_seq h1 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h_post out_u) (UV.as_seq h_post inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b' in length_aux3 auth_b' (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h1 auth_u) (UV.as_seq h1 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h_post tag_b)) tag )); lemma_identical_uv out_b' h_post h2; lemma_identical_uv inout_b h_post h2; assert (let out_d = get_downview out_b' in length_aux3 out_b' (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in UV.as_seq h_post out_u == UV.as_seq h2 out_u); assert (let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in UV.as_seq h_post inout_u == UV.as_seq h2 inout_u); lemma_slice_sub plain_b plain_b' inout_b h1; lemma_slice_uv_extra plain_b plain_b' inout_b h1; lemma_slice_sub auth_b auth_b' abytes_b h1; lemma_slice_sub out_b out_b' inout_b h2; lemma_slice_uv_extra auth_b auth_b' abytes_b h1; lemma_slice_uv_extra out_b out_b' inout_b h2; assert (let plain = seq_uint8_to_seq_nat8 (B.as_seq h1 plain_b) in let auth = seq_uint8_to_seq_nat8 (B.as_seq h1 auth_b) in let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain auth in Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h2 out_b)) cipher /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h2 tag_b)) tag); pop_frame ()
{ "checked_file": "Vale.Wrapper.X64.GCMencryptOpt.fst.checked", "dependencies": [ "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Stdcalls.X64.GCMencryptOpt.fst.checked", "Vale.SHA.Simplify_Sha.fsti.checked", "Vale.Lib.BufferViewHelpers.fst.checked", "Vale.Interop.Views.fsti.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Gcm_simplify.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "prims.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Integers.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Wrapper.X64.GCMencryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Wrapper.X64.GCMencryptOpt.uint8_p", "Vale.Wrapper.X64.GCMencryptOpt.uint64", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Prims._assert", "Vale.Def.Types_s.nat8", "Prims.l_and", "FStar.Seq.Base.equal", "Vale.Def.Words_s.nat8", "Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8", "LowStar.Monotonic.Buffer.as_seq", "FStar.UInt8.t", "LowStar.Buffer.trivial_preorder", "FStar.Pervasives.Native.tuple2", "Vale.AES.GCM_s.gcm_encrypt_LE", "Vale.AES.AES_common_s.AES_128", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE", "FStar.Ghost.reveal", "Vale.Wrapper.X64.GCMencryptOpt.lemma_slice_uv_extra", "Vale.Wrapper.X64.GCMencryptOpt.lemma_slice_sub", "Prims.eq2", "FStar.Seq.Properties.lseq", "Vale.Def.Types_s.quad32", "LowStar.BufferView.Up.length", "LowStar.BufferView.Up.as_seq", "LowStar.BufferView.Up.buffer", "LowStar.BufferView.Up.mk_buffer", "Vale.Interop.Views.up_view128", "Vale.Wrapper.X64.GCMencryptOpt.length_aux3", "LowStar.BufferView.Down.buffer", "Vale.Interop.Types.get_downview", "Vale.Arch.HeapTypes_s.TUInt8", "FStar.Integers.op_Slash", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.UInt64.v", "Vale.Wrapper.X64.GCMencryptOpt.lemma_identical_uv", "Prims.b2t", "FStar.Integers.op_Less", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.logical", "Vale.Wrapper.X64.GCMencryptOpt.wrap_slice", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "FStar.Seq.Base.append", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Monotonic.Buffer.blit", "FStar.UInt32.__uint_to_t", "FStar.Integers.op_Star", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Int.Cast.uint64_to_uint32", "FStar.Integers.op_Percent", "Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_alloca", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.sub", "FStar.Ghost.hide", "FStar.UInt32.t", "FStar.Integers.int_t", "Vale.Wrapper.X64.GCMencryptOpt.math_cast_aux", "FStar.HyperStack.ST.push_frame" ]
[]
module Vale.Wrapper.X64.GCMencryptOpt #reset-options "--z3rlimit 50" let z3rlimit_hack x = () open FStar.Mul open Vale.Stdcalls.X64.GCMencryptOpt open Vale.AsLowStar.MemoryHelpers open Vale.X64.MemoryAdapters module V = Vale.X64.Decls open Vale.SHA.Simplify_Sha open Vale.AES.Gcm_simplify open Vale.AES.GCM_helpers open FStar.Calc open FStar.Int.Cast open FStar.Integers open Vale.Arch.Types open Vale.Lib.BufferViewHelpers let wrap_slice (#a:Type0) (s:Seq.seq a) (i:int) : Seq.seq a = Seq.slice s 0 (if 0 <= i && i <= Seq.length s then i else 0) #reset-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" let math_aux (n:nat) : Lemma (n * 1 == n) = () let length_div (b:uint8_p) : Lemma (requires B.length b = 16) (ensures DV.length (get_downview b) / 16 = 1) = DV.length_eq (get_downview b) inline_for_extraction val gcm128_encrypt_opt': key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> auth_b:uint8_p -> auth_bytes:uint64 -> auth_num:uint64 -> keys_b:uint8_p -> iv_b:uint8_p -> hkeys_b:uint8_p -> abytes_b:uint8_p -> in128x6_b:uint8_p -> out128x6_b:uint8_p -> len128x6:uint64 -> in128_b:uint8_p -> out128_b:uint8_p -> len128_num:uint64 -> inout_b:uint8_p -> plain_num:uint64 -> scratch_b:uint8_p -> tag_b:uint8_p -> Stack unit (requires fun h0 -> B.disjoint tag_b keys_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b abytes_b /\ B.disjoint tag_b iv_b /\ B.disjoint tag_b in128x6_b /\ B.disjoint tag_b out128x6_b /\ B.disjoint tag_b in128_b /\ B.disjoint tag_b out128_b /\ B.disjoint tag_b inout_b /\ B.disjoint tag_b scratch_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b auth_b /\ B.disjoint iv_b abytes_b /\ B.disjoint iv_b in128x6_b /\ B.disjoint iv_b out128x6_b /\ B.disjoint iv_b in128_b /\ B.disjoint iv_b out128_b /\ B.disjoint iv_b inout_b /\ B.disjoint iv_b scratch_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint scratch_b in128x6_b /\ B.disjoint scratch_b out128x6_b /\ B.disjoint scratch_b in128_b /\ B.disjoint scratch_b out128_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b abytes_b /\ B.disjoint inout_b in128x6_b /\ B.disjoint inout_b out128x6_b /\ B.disjoint inout_b in128_b /\ B.disjoint inout_b out128_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint out128x6_b keys_b /\ B.disjoint out128x6_b auth_b /\ B.disjoint out128x6_b abytes_b /\ B.disjoint out128x6_b hkeys_b /\ B.disjoint out128x6_b in128_b /\ B.disjoint out128x6_b inout_b /\ B.disjoint in128x6_b keys_b /\ B.disjoint in128x6_b auth_b /\ B.disjoint in128x6_b abytes_b /\ B.disjoint in128x6_b hkeys_b /\ B.disjoint in128x6_b in128_b /\ B.disjoint in128x6_b inout_b /\ B.disjoint out128_b keys_b /\ B.disjoint out128_b auth_b /\ B.disjoint out128_b abytes_b /\ B.disjoint out128_b hkeys_b /\ B.disjoint out128_b in128x6_b /\ B.disjoint out128_b out128x6_b /\ B.disjoint out128_b inout_b /\ B.disjoint in128_b keys_b /\ B.disjoint in128_b auth_b /\ B.disjoint in128_b abytes_b /\ B.disjoint in128_b hkeys_b /\ B.disjoint in128_b in128x6_b /\ B.disjoint in128_b out128x6_b /\ B.disjoint in128_b inout_b /\ B.disjoint keys_b abytes_b /\ B.disjoint hkeys_b auth_b /\ B.disjoint hkeys_b abytes_b /\ B.disjoint auth_b abytes_b /\ B.disjoint keys_b auth_b /\ disjoint_or_eq in128x6_b out128x6_b /\ disjoint_or_eq in128_b out128_b /\ disjoint_or_eq keys_b hkeys_b /\ B.live h0 auth_b /\ B.live h0 abytes_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 in128x6_b /\ B.live h0 out128x6_b /\ B.live h0 in128_b /\ B.live h0 out128_b /\ B.live h0 inout_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.length auth_b = 16 * UInt64.v auth_num /\ B.length abytes_b == 16 /\ B.length iv_b = 16 /\ B.length in128x6_b == 16 * UInt64.v len128x6 /\ B.length out128x6_b == B.length in128x6_b /\ B.length in128_b == 16 * UInt64.v len128_num /\ B.length out128_b == B.length in128_b /\ B.length inout_b == 16 /\ B.length scratch_b == 144 /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ UInt64.v plain_num < pow2_32 /\ UInt64.v auth_bytes < pow2_32 /\ UInt64.v len128x6 % 6 == 0 /\ (UInt64.v len128x6 > 0 ==> UInt64.v len128x6 >= 18) /\ 12 + UInt64.v len128x6 + 6 < pow2_32 /\ UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) <= UInt64.v plain_num /\ UInt64.v plain_num < UInt64.v len128x6 * (128/8) + UInt64.v len128_num * (128/8) + 128/8 /\ UInt64.v auth_num * (128/8) <= UInt64.v auth_bytes /\ UInt64.v auth_bytes < UInt64.v auth_num * (128/8) + 128/8 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) /\ (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in hkeys_reqs_pub (UV.as_seq h0 ub) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)))) /\ (length_div iv_b; (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out128x6_b) (B.loc_union (B.loc_buffer out128_b) (B.loc_buffer inout_b)))))) h0 h1 /\ ((UInt64.v plain_num) < pow2_32 /\ (UInt64.v auth_bytes) < pow2_32 /\ ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_num) in let cipher_out = Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_num) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_num); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_bytes) in (Seq.length plain_bytes) < pow2_32 /\ (Seq.length auth_bytes) < pow2_32 /\ is_aes_key AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in cipher == cipher_bytes /\ (length_div tag_b; le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h1 tag_b 0) == tag )))) ) #push-options "--z3cliopt smt.arith.nl=true --retry 3 --z3rlimit 800 --ext compat:normalizer_memo_ignore_cfg" #restart-solver inline_for_extraction let gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b = let h0 = get() in B.disjoint_neq iv_b auth_b; B.disjoint_neq iv_b keys_b; B.disjoint_neq iv_b hkeys_b; B.disjoint_neq iv_b abytes_b; B.disjoint_neq iv_b in128x6_b; B.disjoint_neq iv_b out128x6_b; B.disjoint_neq iv_b in128_b; B.disjoint_neq iv_b out128_b; B.disjoint_neq iv_b inout_b; B.disjoint_neq iv_b scratch_b; B.disjoint_neq iv_b tag_b; DV.length_eq (get_downview auth_b); DV.length_eq (get_downview keys_b); DV.length_eq (get_downview iv_b); DV.length_eq (get_downview hkeys_b); DV.length_eq (get_downview abytes_b); DV.length_eq (get_downview in128x6_b); DV.length_eq (get_downview out128x6_b); DV.length_eq (get_downview in128_b); DV.length_eq (get_downview out128_b); DV.length_eq (get_downview inout_b); DV.length_eq (get_downview scratch_b); DV.length_eq (get_downview tag_b); math_aux (B.length auth_b); math_aux (B.length keys_b); math_aux (B.length iv_b); math_aux (B.length hkeys_b); math_aux (B.length in128x6_b); math_aux (B.length scratch_b); math_aux (B.length out128_b); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v auth_num) 16; assert_norm (176 % 16 = 0); assert_norm (16 % 16 = 0); assert_norm (144 % 16 = 0); FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128x6) 16; FStar.Math.Lemmas.cancel_mul_mod (UInt64.v len128_num) 16; calc (<=) { 256 * ((16 * UInt64.v len128_num) / 16); (==) { FStar.Math.Lemmas.cancel_mul_div (UInt64.v len128_num) 16 } 256 * (UInt64.v len128_num); ( <= ) { assert_norm (256 <= 4096); FStar.Math.Lemmas.lemma_mult_le_right (UInt64.v len128_num) 256 4096 } 4096 * (UInt64.v len128_num); }; assert (DV.length (get_downview tag_b) % 16 = 0); assert (DV.length (get_downview scratch_b) % 16 = 0); assert (DV.length (get_downview out128_b) % 16 = 0); as_vale_buffer_len #TUInt8 #TUInt128 auth_b; as_vale_buffer_len #TUInt8 #TUInt128 keys_b; as_vale_buffer_len #TUInt8 #TUInt128 iv_b; as_vale_buffer_len #TUInt8 #TUInt128 hkeys_b; as_vale_buffer_len #TUInt8 #TUInt128 abytes_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 out128x6_b; as_vale_buffer_len #TUInt8 #TUInt128 in128_b; as_vale_buffer_len #TUInt8 #TUInt128 inout_b; as_vale_buffer_len #TUInt8 #TUInt128 scratch_b; as_vale_buffer_len #TUInt8 #TUInt128 tag_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 auth_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128x6_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 in128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 out128_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 inout_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 iv_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 keys_b; bounded_buffer_addrs_all TUInt8 TUInt128 h0 hkeys_b; let (x, _) = gcm128_encrypt_opt key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6 in128_b out128_b len128_num inout_b plain_num scratch_b tag_b () in let h1 = get() in () #pop-options inline_for_extraction val gcm128_encrypt_opt_alloca: key:Ghost.erased (Seq.seq nat32) -> iv:Ghost.erased supported_iv_LE -> plain_b:uint8_p -> plain_len:uint64 -> auth_b:uint8_p -> auth_len:uint64 -> iv_b:uint8_p -> out_b:uint8_p -> tag_b:uint8_p -> keys_b:uint8_p -> hkeys_b:uint8_p -> scratch_b:uint8_p -> inout_b : uint8_p -> abytes_b : uint8_p -> Stack unit (requires fun h0 -> B.disjoint scratch_b tag_b /\ B.disjoint scratch_b out_b /\ B.disjoint scratch_b hkeys_b /\ B.disjoint scratch_b plain_b /\ B.disjoint scratch_b auth_b /\ B.disjoint scratch_b iv_b /\ B.disjoint scratch_b keys_b /\ B.disjoint scratch_b inout_b /\ B.disjoint scratch_b abytes_b /\ B.disjoint inout_b tag_b /\ B.disjoint inout_b out_b /\ B.disjoint inout_b hkeys_b /\ B.disjoint inout_b plain_b /\ B.disjoint inout_b auth_b /\ B.disjoint inout_b iv_b /\ B.disjoint inout_b keys_b /\ B.disjoint inout_b abytes_b /\ B.disjoint abytes_b tag_b /\ B.disjoint abytes_b out_b /\ B.disjoint abytes_b hkeys_b /\ B.disjoint abytes_b plain_b /\ B.disjoint abytes_b auth_b /\ B.disjoint abytes_b iv_b /\ B.disjoint abytes_b keys_b /\ B.disjoint tag_b out_b /\ B.disjoint tag_b hkeys_b /\ B.disjoint tag_b plain_b /\ B.disjoint tag_b auth_b /\ B.disjoint tag_b iv_b /\ disjoint_or_eq tag_b keys_b /\ B.disjoint iv_b keys_b /\ B.disjoint iv_b out_b /\ B.disjoint iv_b plain_b /\ B.disjoint iv_b hkeys_b /\ B.disjoint iv_b auth_b /\ B.disjoint out_b keys_b /\ B.disjoint out_b hkeys_b /\ B.disjoint out_b auth_b /\ disjoint_or_eq out_b plain_b /\ B.disjoint plain_b keys_b /\ B.disjoint plain_b hkeys_b /\ B.disjoint plain_b auth_b /\ disjoint_or_eq keys_b hkeys_b /\ B.disjoint keys_b auth_b /\ B.disjoint hkeys_b auth_b /\ B.live h0 auth_b /\ B.live h0 keys_b /\ B.live h0 iv_b /\ B.live h0 hkeys_b /\ B.live h0 out_b /\ B.live h0 plain_b /\ B.live h0 tag_b /\ B.live h0 scratch_b /\ B.live h0 inout_b /\ B.live h0 abytes_b /\ B.length auth_b = (UInt64.v auth_len / 16) * 16 /\ B.length iv_b = 16 /\ B.length plain_b = (UInt64.v plain_len / 16) * 16 /\ B.length out_b = B.length plain_b /\ B.length hkeys_b = 128 /\ B.length tag_b == 16 /\ B.length keys_b = 176 /\ B.length scratch_b = 144 /\ B.length inout_b = 16 /\ B.length abytes_b = 16 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ sse_enabled /\ movbe_enabled /\ is_aes_key_LE AES_128 (Ghost.reveal key) /\ (Seq.equal (B.as_seq h0 keys_b) (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key))))) /\ hkeys_reqs_pub (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) (reverse_bytes_quad32 (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0))) /\ (le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b))) == compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv) ) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer tag_b) (B.loc_union (B.loc_buffer iv_b) (B.loc_union (B.loc_buffer scratch_b) (B.loc_union (B.loc_buffer out_b) (B.loc_buffer inout_b))))) h0 h1 /\ UInt64.v plain_len < pow2_32 /\ UInt64.v auth_len < pow2_32 /\ (let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in let plain_in = Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u) in let plain_bytes = wrap_slice (le_seq_quad32_to_bytes plain_in) (UInt64.v plain_len) in let cipher_out = Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u) in let cipher_bytes = wrap_slice (le_seq_quad32_to_bytes cipher_out) (UInt64.v plain_len) in let auth_d = get_downview auth_b in length_aux3 auth_b (UInt64.v auth_len / 16); let auth_u = UV.mk_buffer auth_d Vale.Interop.Views.up_view128 in let abytes_d = get_downview abytes_b in length_aux3 abytes_b 1; let abytes_u = UV.mk_buffer abytes_d Vale.Interop.Views.up_view128 in let auth_in = Seq.append (UV.as_seq h0 auth_u) (UV.as_seq h0 abytes_u) in let auth_bytes = wrap_slice (le_seq_quad32_to_bytes auth_in) (UInt64.v auth_len) in Seq.length plain_bytes < pow2_32 /\ Seq.length auth_bytes < pow2_32 /\ (let cipher, tag = gcm_encrypt_LE AES_128 (seq_nat32_to_seq_nat8_LE (Ghost.reveal key)) (Ghost.reveal iv) plain_bytes auth_bytes in Seq.equal cipher cipher_bytes /\ Seq.equal (seq_uint8_to_seq_nat8 (B.as_seq h1 tag_b)) tag ) )) let lemma_same_seq_dv (h:HS.mem) (b:uint8_p) : Lemma (Seq.equal (B.as_seq h b) (DV.as_seq h (get_downview b))) = let db = get_downview b in DV.length_eq db; let aux (i:nat{i < B.length b}) : Lemma (Seq.index (B.as_seq h b) i == Seq.index (DV.as_seq h db) i) = DV.as_seq_sel h db i; DV.get_sel h db i; Vale.Interop.Views.put8_reveal () in Classical.forall_intro aux let lemma_uv_split (h:HS.mem) (b:uint8_p) (n:UInt32.t) : Lemma (requires B.length b % 16 = 0 /\ UInt32.v n % 16 = 0 /\ UInt32.v n <= B.length b) (ensures ( let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in Seq.equal bs split_bs) ) = let b1 = B.gsub b 0ul n in let b2 = B.gsub b n (UInt32.uint_to_t (B.length b) - n) in let b1_d = get_downview b1 in length_aux3 b1 (B.length b1 / 16); let b1_u = UV.mk_buffer b1_d Vale.Interop.Views.up_view128 in let b2_d = get_downview b2 in length_aux3 b2 (B.length b2 / 16); let b2_u = UV.mk_buffer b2_d Vale.Interop.Views.up_view128 in let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in let split_bs = Seq.append (UV.as_seq h b1_u) (UV.as_seq h b2_u) in let bs = UV.as_seq h b_u in calc (==) { Seq.length split_bs; (==) { } Seq.length (UV.as_seq h b1_u) + Seq.length (UV.as_seq h b2_u); (==) { UV.length_eq b1_u; UV.length_eq b2_u } DV.length b1_d / 16 + DV.length b2_d / 16; (==) { DV.length_eq b1_d; DV.length_eq b2_d; math_aux (B.length b1); math_aux (B.length b2) } B.length b1 / 16 + B.length b2 / 16; (==) { } B.length b / 16; (==) { DV.length_eq b_d; UV.length_eq b_u; math_aux (B.length b) } Seq.length bs; }; assert (Seq.length bs == Seq.length split_bs); let aux (i:nat{ i < Seq.length bs}) : Lemma (Seq.index bs i = Seq.index split_bs i) = UV.length_eq b_u; lemma_same_seq_dv h b; calc (==) { Seq.index bs i; (==) { UV.as_seq_sel h b_u i } UV.sel h b_u i; (==) { UV.get_sel h b_u i } Vale.Interop.Views.get128 (Seq.slice (DV.as_seq h b_d) (i * 16) (i * 16 + 16)); (==) { lemma_same_seq_dv h b } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b) (i * 16) (i * 16 + 16)); (==) { assert (Seq.equal (B.as_seq h b) (Seq.append (B.as_seq h b1) (B.as_seq h b2))) } Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); }; if i < Seq.length (UV.as_seq h b1_u) then ( lemma_same_seq_dv h b1; UV.length_eq b1_u; calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b1) (i * 16) (i * 16 + 16)); (==) { UV.get_sel h b1_u i } UV.sel h b1_u i; (==) { UV.as_seq_sel h b1_u i } Seq.index (UV.as_seq h b1_u) i; (==) { } Seq.index split_bs i; } ) else ( lemma_same_seq_dv h b2; UV.length_eq b2_u; let j = i - UV.length b1_u in calc (==) { Vale.Interop.Views.get128 (Seq.slice (Seq.append (B.as_seq h b1) (B.as_seq h b2)) (i * 16) (i * 16 + 16)); (==) { } Vale.Interop.Views.get128 (Seq.slice (B.as_seq h b2) (j * 16) (j * 16 + 16)); (==) { UV.get_sel h b2_u j } UV.sel h b2_u j; (==) { UV.as_seq_sel h b2_u j } Seq.index (UV.as_seq h b2_u) j; (==) { } Seq.index split_bs i; } ) in Classical.forall_intro aux let math_cast_aux (n:UInt64.t) : Lemma (requires UInt64.v n < pow2 32) (ensures UInt32.v (uint64_to_uint32 n) = UInt64.v n) = FStar.Math.Lemmas.small_mod (UInt64.v n) (pow2 32) inline_for_extraction let gcm128_encrypt_opt_alloca key iv plain_b plain_len auth_b auth_bytes iv_b out_b tag_b keys_b hkeys_b scratch_b inout_b abytes_b = let h0 = get() in let lemma_uv_key () : Lemma (let db = get_downview keys_b in length_aux keys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 ub) (key_to_round_keys_LE AES_128 (Ghost.reveal key))) = length_aux keys_b; let db = get_downview keys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in le_bytes_to_seq_quad32_to_bytes (key_to_round_keys_LE AES_128 (Ghost.reveal key)); assert (Seq.equal (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b))) (key_to_round_keys_LE AES_128 (Ghost.reveal key))); calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 keys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 keys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_key (); // Simplify the precondition for hkeys_b let lemma_uv_hkey () : Lemma (let db = get_downview hkeys_b in length_aux5 hkeys_b; let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in UV.as_seq h0 ub == le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b))) = length_aux5 hkeys_b; let db = get_downview hkeys_b in let ub = UV.mk_buffer db Vale.Interop.Views.up_view128 in calc (==) { le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 hkeys_b)); (==) { lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 hkeys_b h0 } le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (UV.as_seq h0 ub)))); (==) { le_bytes_to_seq_quad32_to_bytes (UV.as_seq h0 ub) } UV.as_seq h0 ub; } in lemma_uv_hkey (); // Simplify the expression for the iv DV.length_eq (get_downview iv_b); length_aux4 iv_b; calc (==) { compute_iv_BE (aes_encrypt_LE AES_128 (Ghost.reveal key) (Mkfour 0 0 0 0)) (Ghost.reveal iv); (==) { } le_bytes_to_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h0 iv_b)); (==) { gcm_simplify2 iv_b h0 } le_bytes_to_quad32 (le_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0)); (==) { le_bytes_to_quad32_to_bytes (low_buffer_read TUInt8 TUInt128 h0 iv_b 0) } low_buffer_read TUInt8 TUInt128 h0 iv_b 0; }; // Compute length of biggest blocks of 6 * 128-bit blocks let len128x6 = UInt64.mul (plain_len / 96uL) 96uL in if len128x6 / 16uL >= 18uL then ( let len128_num = ((plain_len / 16uL) * 16uL) - len128x6 in // Casting to uint32 is here the equality math_cast_aux len128x6; math_cast_aux len128_num; let in128x6_b = B.sub plain_b 0ul (uint64_to_uint32 len128x6) in let out128x6_b = B.sub out_b 0ul (uint64_to_uint32 len128x6) in let in128_b = B.sub plain_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b (uint64_to_uint32 len128x6) (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128x6' = UInt64.div len128x6 16uL in let len128_num' = UInt64.div len128_num 16uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b (uint64_to_uint32 len128x6); // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b (uint64_to_uint32 len128x6); assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ) else ( let len128x6 = 0ul in // Compute the size of the remaining 128-bit blocks let len128_num = ((plain_len / 16uL) * 16uL) in // Casting to uint32 is here the equality FStar.Math.Lemmas.small_mod (UInt64.v len128_num) pow2_32; let in128x6_b = B.sub plain_b 0ul len128x6 in let out128x6_b = B.sub out_b 0ul len128x6 in let in128_b = B.sub plain_b len128x6 (uint64_to_uint32 len128_num) in let out128_b = B.sub out_b len128x6 (uint64_to_uint32 len128_num) in let auth_num = UInt64.div auth_bytes 16uL in let len128_num' = UInt64.div len128_num 16uL in let len128x6' = 0uL in gcm128_encrypt_opt' key iv auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6' in128_b out128_b len128_num' inout_b plain_len scratch_b tag_b; let h1 = get() in lemma_uv_split h0 plain_b len128x6; // Still need the two asserts for z3 to pick up seq equality assert ( let in128x6_d = get_downview in128x6_b in length_aux3 in128x6_b (UInt64.v len128x6'); let in128x6_u = UV.mk_buffer in128x6_d Vale.Interop.Views.up_view128 in let in128_d = get_downview in128_b in length_aux3 in128_b (UInt64.v len128_num'); let in128_u = UV.mk_buffer in128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let plain_d = get_downview plain_b in length_aux3 plain_b (UInt64.v plain_len / 16); let plain_u = UV.mk_buffer plain_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h0 in128x6_u) (UV.as_seq h0 in128_u)) (UV.as_seq h0 inout_u)) (Seq.append (UV.as_seq h0 plain_u) (UV.as_seq h0 inout_u))); lemma_uv_split h1 out_b len128x6; assert ( let out128x6_d = get_downview out128x6_b in length_aux3 out128x6_b (UInt64.v len128x6'); let out128x6_u = UV.mk_buffer out128x6_d Vale.Interop.Views.up_view128 in let out128_d = get_downview out128_b in length_aux3 out128_b (UInt64.v len128_num'); let out128_u = UV.mk_buffer out128_d Vale.Interop.Views.up_view128 in let inout_d = get_downview inout_b in length_aux3 inout_b 1; let inout_u = UV.mk_buffer inout_d Vale.Interop.Views.up_view128 in let out_d = get_downview out_b in length_aux3 out_b (UInt64.v plain_len / 16); let out_u = UV.mk_buffer out_d Vale.Interop.Views.up_view128 in Seq.equal (Seq.append (Seq.append (UV.as_seq h1 out128x6_u) (UV.as_seq h1 out128_u)) (UV.as_seq h1 inout_u)) (Seq.append (UV.as_seq h1 out_u) (UV.as_seq h1 inout_u))) ); // Simplify post condition for tag let h_f = get() in gcm_simplify2 tag_b h_f let lemma_identical_uv (b:uint8_p) (h0 h1:HS.mem) : Lemma (requires B.length b % 16 = 0 /\ Seq.equal (B.as_seq h0 b) (B.as_seq h1 b)) (ensures ( let b_d = get_downview b in length_aux3 b (B.length b / 16); let b_u = UV.mk_buffer b_d Vale.Interop.Views.up_view128 in Seq.equal (UV.as_seq h0 b_u) (UV.as_seq h1 b_u))) = lemma_dv_equal Vale.Interop.Views.down_view8 b h0 h1; length_aux3 b (B.length b / 16); lemma_uv_equal Vale.Interop.Views.up_view128 (get_downview b) h0 h1 let length_aux6 (b:uint8_p) : Lemma (B.length b = DV.length (get_downview b)) = DV.length_eq (get_downview b) #push-options "--z3cliopt smt.arith.nl=true" let lemma_slice_uv_extra (b:uint8_p) (b_start:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma (requires B.length b_start = B.length b / 16 * 16 /\ b_start == B.gsub b 0ul (UInt32.uint_to_t (B.length b_start)) /\ B.length b_extra = 16 /\ Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_start) (B.as_seq h b_extra)) 0 (B.length b)) ) (ensures ( let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in Seq.equal sf (seq_uint8_to_seq_nat8 (B.as_seq h b)) )) = let b_start_d = get_downview b_start in length_aux6 b_start; let b_start_u = UV.mk_buffer b_start_d Vale.Interop.Views.up_view128 in let b_extra_d = get_downview b_extra in length_aux6 b_extra; let b_extra_u = UV.mk_buffer b_extra_d Vale.Interop.Views.up_view128 in let suv = Seq.append (UV.as_seq h b_start_u) (UV.as_seq h b_extra_u) in let sf = wrap_slice (le_seq_quad32_to_bytes suv) (B.length b) in let b_f = seq_uint8_to_seq_nat8 (B.as_seq h b) in // if B.length b > B.length b_start then ( calc (==) { sf; (==) { DV.length_eq b_start_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_start h; le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_start_u) } wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (UV.as_seq h b_extra_u))) (B.length b); (==) { DV.length_eq b_extra_d; lemma_seq_nat8_le_seq_quad32_to_bytes_uint32 b_extra h; le_bytes_to_seq_quad32_to_bytes (UV.as_seq h b_extra_u) } wrap_slice (le_seq_quad32_to_bytes (Seq.append (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))))) (B.length b); (==) { append_distributes_le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start))) (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) } wrap_slice (Seq.append (le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)))) (le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))))) (B.length b); (==) { le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_start)); le_seq_quad32_to_bytes_to_seq_quad32 (seq_uint8_to_seq_nat8 (B.as_seq h b_extra)) } wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start)) (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) (B.length b); (==) { Seq.lemma_eq_intro b_f (wrap_slice (Seq.append (seq_uint8_to_seq_nat8 (B.as_seq h b_start)) (seq_uint8_to_seq_nat8 (B.as_seq h b_extra))) (B.length b)) } b_f; } // ) else ( // calc (==) { // sf; // (==) { } // wrap_slice (le_seq_quad32_to_bytes (UV.as_seq h b_start_u)) (B.length b); // (==) { DV.length_eq (get_downview b_start); // gcm_simplify1 b_start h (B.length b) } // seq_uint8_to_seq_nat8 (B.as_seq h b_start); // (==) { } // b_f; // } // ) #pop-options let lemma_slice_sub (b:uint8_p) (b_sub:uint8_p) (b_extra:uint8_p) (h:HS.mem) : Lemma (requires B.length b_extra = 16 /\ B.length b_sub = B.length b / 16 * 16 /\ b_sub == B.gsub b 0ul (UInt32.uint_to_t (B.length b_sub)) /\ Seq.equal (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b_sub + B.length b % 16)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)) ) (ensures Seq.equal (B.as_seq h b) (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b)) ) = calc (==) { Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b); (==) { Seq.lemma_eq_intro (Seq.slice (Seq.append (B.as_seq h b_sub) (B.as_seq h b_extra)) 0 (B.length b)) (Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16))) } Seq.append (B.as_seq h b_sub) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)); (==) { } Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub)) (Seq.slice (B.as_seq h b_extra) 0 (B.length b % 16)); (==) { } Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub)) (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b)); (==) { Seq.lemma_eq_intro (B.as_seq h b) (Seq.append (Seq.slice (B.as_seq h b) 0 (B.length b_sub)) (Seq.slice (B.as_seq h b) (B.length b_sub) (B.length b))) } B.as_seq h b; } #set-options "--z3rlimit 600 --max_fuel 0 --max_ifuel 0"
false
true
Vale.Wrapper.X64.GCMencryptOpt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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": 600, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm128_encrypt_opt_stdcall: encrypt_opt_stdcall_st AES_128
[]
Vale.Wrapper.X64.GCMencryptOpt.gcm128_encrypt_opt_stdcall
{ "file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCMencryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Wrapper.X64.GCMencryptOpt.encrypt_opt_stdcall_st Vale.AES.AES_common_s.AES_128
{ "end_col": 13, "end_line": 1003, "start_col": 115, "start_line": 883 }
Prims.Tot
val coerce_eq: #a: Type -> #b: Type -> x: a -> squash (a == b) -> y: b{y == x}
[ { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroPure", "short_module": "IntroPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroExists", "short_module": "IntroExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Match", "short_module": "Match" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimPure", "short_module": "ElimPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimExists", "short_module": "ElimExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Stubs.Pprint", "short_module": "Pprint" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Base", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x
val coerce_eq: #a: Type -> #b: Type -> x: a -> squash (a == b) -> y: b{y == x} let coerce_eq (#a: Type) (#b: Type) (x: a) (_: squash (a == b)) : y: b{y == x} =
false
null
false
x
{ "checked_file": "Pulse.Checker.Prover.fst.checked", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.PP.fst.checked", "Pulse.Config.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.Match.fsti.checked", "Pulse.Checker.Prover.IntroPure.fsti.checked", "Pulse.Checker.Prover.IntroExists.fsti.checked", "Pulse.Checker.Prover.ElimPure.fsti.checked", "Pulse.Checker.Prover.ElimExists.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Prover.fst" }
[ "total" ]
[ "Prims.squash", "Prims.eq2" ]
[]
module Pulse.Checker.Prover open FStar.List.Tot open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Base module L = FStar.List.Tot module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Pprint = FStar.Stubs.Pprint module Metatheory = Pulse.Typing.Metatheory module PS = Pulse.Checker.Prover.Substs module ElimExists = Pulse.Checker.Prover.ElimExists module ElimPure = Pulse.Checker.Prover.ElimPure module Match = Pulse.Checker.Prover.Match module IntroExists = Pulse.Checker.Prover.IntroExists module IntroPure = Pulse.Checker.Prover.IntroPure
false
false
Pulse.Checker.Prover.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val coerce_eq: #a: Type -> #b: Type -> x: a -> squash (a == b) -> y: b{y == x}
[]
Pulse.Checker.Prover.coerce_eq
{ "file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
x: a -> _: Prims.squash (a == b) -> y: b{y == x}
{ "end_col": 70, "end_line": 24, "start_col": 69, "start_line": 24 }
FStar.Tactics.Effect.Tac
val try_frame_pre (#g:env) (#ctxt:vprop) (ctxt_typing:tot_typing g ctxt tm_vprop) (d:(t:st_term & c:comp_st & st_typing g t c)) (res_ppname:ppname) : T.Tac (checker_result_t g ctxt None)
[ { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroPure", "short_module": "IntroPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroExists", "short_module": "IntroExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Match", "short_module": "Match" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimPure", "short_module": "ElimPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimExists", "short_module": "ElimExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Stubs.Pprint", "short_module": "Pprint" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Base", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let try_frame_pre (#g:env) (#ctxt:vprop) (ctxt_typing:tot_typing g ctxt tm_vprop) (d:(t:st_term & c:comp_st & st_typing g t c)) (res_ppname:ppname) : T.Tac (checker_result_t g ctxt None) = let uvs = mk_env (fstar_env g) in assert (equal g (push_env g uvs)); try_frame_pre_uvs ctxt_typing uvs d res_ppname
val try_frame_pre (#g:env) (#ctxt:vprop) (ctxt_typing:tot_typing g ctxt tm_vprop) (d:(t:st_term & c:comp_st & st_typing g t c)) (res_ppname:ppname) : T.Tac (checker_result_t g ctxt None) let try_frame_pre (#g: env) (#ctxt: vprop) (ctxt_typing: tot_typing g ctxt tm_vprop) (d: (t: st_term & c: comp_st & st_typing g t c)) (res_ppname: ppname) : T.Tac (checker_result_t g ctxt None) =
true
null
false
let uvs = mk_env (fstar_env g) in assert (equal g (push_env g uvs)); try_frame_pre_uvs ctxt_typing uvs d res_ppname
{ "checked_file": "Pulse.Checker.Prover.fst.checked", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.PP.fst.checked", "Pulse.Config.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.Match.fsti.checked", "Pulse.Checker.Prover.IntroPure.fsti.checked", "Pulse.Checker.Prover.IntroExists.fsti.checked", "Pulse.Checker.Prover.ElimPure.fsti.checked", "Pulse.Checker.Prover.ElimExists.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Prover.fst" }
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.vprop", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "FStar.Pervasives.dtuple3", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp_st", "Pulse.Typing.st_typing", "Pulse.Syntax.Base.ppname", "Pulse.Checker.Prover.try_frame_pre_uvs", "Pulse.Checker.Base.checker_result_t", "FStar.Pervasives.Native.None", "Pulse.Typing.post_hint_t", "Prims.unit", "Prims._assert", "Pulse.Typing.Env.equal", "Pulse.Typing.Env.push_env", "Prims.eq2", "FStar.Reflection.Typing.fstar_top_env", "Pulse.Typing.Env.fstar_env", "Pulse.Typing.Env.mk_env" ]
[]
module Pulse.Checker.Prover open FStar.List.Tot open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Base module L = FStar.List.Tot module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Pprint = FStar.Stubs.Pprint module Metatheory = Pulse.Typing.Metatheory module PS = Pulse.Checker.Prover.Substs module ElimExists = Pulse.Checker.Prover.ElimExists module ElimPure = Pulse.Checker.Prover.ElimPure module Match = Pulse.Checker.Prover.Match module IntroExists = Pulse.Checker.Prover.IntroExists module IntroPure = Pulse.Checker.Prover.IntroPure let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x let unsolved_equiv_pst (#preamble:_) (pst:prover_state preamble) (unsolved':list vprop) (d:vprop_equiv (push_env pst.pg pst.uvs) (list_as_vprop pst.unsolved) (list_as_vprop unsolved')) : prover_state preamble = { pst with unsolved = unsolved'; goals_inv = magic () } let remaining_ctxt_equiv_pst (#preamble:_) (pst:prover_state preamble) (remaining_ctxt':list vprop) (d:vprop_equiv pst.pg (list_as_vprop pst.remaining_ctxt) (list_as_vprop remaining_ctxt')) : prover_state preamble = { pst with remaining_ctxt = remaining_ctxt'; remaining_ctxt_frame_typing = magic (); k = k_elab_equiv pst.k (VE_Refl _ _) (magic ()) } let rec collect_exists (g:env) (l:list vprop) : exs:list vprop & rest:list vprop & vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) = match l with | [] -> (| [], [], VE_Refl _ _ |) | hd::tl -> let (| exs, rest, _ |) = collect_exists g tl in match hd.t with | Tm_ExistsSL _ _ _ -> (| hd::exs, rest, magic () |) | _ -> (| exs, hd::rest, magic () |) let rec collect_pures (g:env) (l:list vprop) : pures:list vprop & rest:list vprop & vprop_equiv g (list_as_vprop l) (list_as_vprop (rest @ pures)) = match l with | [] -> (| [], [], VE_Refl _ _ |) | hd::tl -> let (| pures, rest, _ |) = collect_pures g tl in match hd.t with | Tm_Pure _ -> (| hd::pures, rest, magic () |) | _ -> (| pures, hd::rest, magic () |) let move_hd_end (g:env) (l:list vprop { Cons? l }) : vprop_equiv g (list_as_vprop l) (list_as_vprop (L.tl l @ [L.hd l])) = magic () let rec match_q (#preamble:_) (pst:prover_state preamble) (q:vprop) (unsolved':list vprop) (_:squash (pst.unsolved == q::unsolved')) (i:nat) : T.Tac (option (pst':prover_state preamble { pst' `pst_extends` pst })) = if L.length pst.remaining_ctxt = 0 then None else if i = L.length pst.remaining_ctxt then None else let p = L.hd pst.remaining_ctxt in let pst_opt = Match.match_step pst p (L.tl pst.remaining_ctxt) q unsolved' () in match pst_opt with | Some pst -> Some pst | None -> let pst = remaining_ctxt_equiv_pst pst (L.tl pst.remaining_ctxt @ [L.hd pst.remaining_ctxt]) (move_hd_end pst.pg pst.remaining_ctxt) in match_q pst q unsolved' () (i+1) let rec prove_pures #preamble (pst:prover_state preamble) : T.Tac (pst':prover_state preamble { pst' `pst_extends` pst /\ is_terminal pst' }) = match pst.unsolved with | [] -> pst | {t=Tm_Pure p}::unsolved' -> let pst_opt = IntroPure.intro_pure pst p unsolved' () in (match pst_opt with | None -> let open Pulse.PP in fail_doc pst.pg None [ text "Cannot prove pure proposition" ^/^ pp p ] | Some pst1 -> let pst2 = prove_pures pst1 in assert (pst1 `pst_extends` pst); assert (pst2 `pst_extends` pst1); assert (pst2 `pst_extends` pst); pst2) | _ -> fail pst.pg None (Printf.sprintf "Impossible! prover.prove_pures: %s is not a pure, please file a bug-report" (P.term_to_string (L.hd pst.unsolved))) #push-options "--z3rlimit_factor 4" let rec prover (#preamble:_) (pst0:prover_state preamble) : T.Tac (pst':prover_state preamble { pst' `pst_extends` pst0 /\ is_terminal pst' }) = debug_prover pst0.pg (fun _ -> Printf.sprintf "At the prover top-level with remaining_ctxt: %s\nunsolved: %s" (P.term_to_string (list_as_vprop pst0.remaining_ctxt)) (P.term_to_string (list_as_vprop pst0.unsolved))); match pst0.unsolved with | [] -> pst0 | _ -> let pst = ElimExists.elim_exists_pst pst0 in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: remaining_ctxt after elim exists: %s\n" (P.term_to_string (list_as_vprop pst.remaining_ctxt))); let pst = ElimPure.elim_pure_pst pst in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: remaining_ctxt after elim pure: %s\n" (P.term_to_string (list_as_vprop pst.remaining_ctxt))); let (| exs, rest, d |) = collect_exists (push_env pst.pg pst.uvs) pst.unsolved in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: tried to pull exists: exs: %s and rest: %s\n" (P.term_to_string (list_as_vprop exs)) (P.term_to_string (list_as_vprop rest))); let pst = unsolved_equiv_pst pst (exs@rest) d in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: unsolved after pulling exists at the top: %s\n" (P.term_to_string (list_as_vprop pst.unsolved))); match pst.unsolved with | {t=Tm_ExistsSL u b body}::unsolved' -> IntroExists.intro_exists pst u b body unsolved' () prover | _ -> let (| pures, rest, d |) = collect_pures (push_env pst.pg pst.uvs) pst.unsolved in let pst = unsolved_equiv_pst pst (rest@pures) d in match pst.unsolved with | {t=Tm_Pure _}::tl -> prove_pures pst | q::tl -> let pst_opt = match_q pst q tl () 0 in match pst_opt with | None -> let open Pprint in let open Pulse.PP in let msg = [ text "Error in proving precondition"; text "Cannot prove:" ^^ indent (pp q); text "In the context:" ^^ indent (pp (list_as_vprop pst.remaining_ctxt)) ] @ (if Pulse.Config.debug_flag "initial_solver_state" then [ text "The prover was started with goal:" ^^ indent (pp preamble.goals); text "and initial context:" ^^ indent (pp preamble.ctxt); ] else []) in // GM: I feel I should use (Some q.range) instead of None, but that makes // several error locations worse. fail_doc pst.pg None msg | Some pst -> prover pst // a little wasteful? #pop-options let rec get_q_at_hd (g:env) (l:list vprop) (q:vprop { L.existsb (fun v -> eq_tm v q) l }) : l':list vprop & vprop_equiv g (list_as_vprop l) (q * list_as_vprop l') = match l with | hd::tl -> if eq_tm hd q then (| tl, magic () |) else let (| tl', _ |) = get_q_at_hd g tl q in (| hd::tl', magic () |) #push-options "--z3rlimit_factor 4" let prove (#g:env) (#ctxt:vprop) (ctxt_typing:vprop_typing g ctxt) (uvs:env { disjoint g uvs }) (#goals:vprop) (goals_typing:vprop_typing (push_env g uvs) goals) : T.Tac (g1 : env { g1 `env_extends` g /\ disjoint g1 uvs } & nts : PS.nt_substs { PS.well_typed_nt_substs g1 uvs nts } & remaining_ctxt : vprop & continuation_elaborator g ctxt g1 ((PS.nt_subst_term goals nts) * remaining_ctxt)) = debug_prover g (fun _ -> Printf.sprintf "\nEnter top-level prove with ctxt: %s\ngoals: %s\n" (P.term_to_string ctxt) (P.term_to_string goals)); let ctxt_l = vprop_as_list ctxt in if false && Nil? (bindings uvs) && L.existsb (fun v -> eq_tm v goals) ctxt_l then begin let (| l', d_eq |) = get_q_at_hd g ctxt_l goals in let g1 = g in let nts : PS.nt_substs = [] in let remaining_ctxt = list_as_vprop l' in let k : continuation_elaborator g ctxt g1 ctxt = k_elab_unit g ctxt in assume (list_as_vprop (vprop_as_list ctxt) == ctxt); let d_eq : vprop_equiv g ctxt ((PS.nt_subst_term goals nts) * remaining_ctxt) = coerce_eq d_eq () in (| g1, nts, remaining_ctxt, k_elab_equiv k (VE_Refl _ _) d_eq |) end else let ctxt_frame_typing : vprop_typing g (ctxt * tm_emp) = magic () in let preamble = { g0 = g; ctxt; frame = tm_emp; ctxt_frame_typing; goals; } in assume (list_as_vprop (vprop_as_list ctxt) == ctxt); assume ((PS.empty).(tm_emp) == tm_emp); let pst0 : prover_state preamble = { pg = g; remaining_ctxt = vprop_as_list ctxt; remaining_ctxt_frame_typing = ctxt_frame_typing; uvs = uvs; ss = PS.empty; solved = tm_emp; unsolved = vprop_as_list goals; k = k_elab_equiv (k_elab_unit g ctxt) (magic ()) (magic ()); goals_inv = magic (); solved_inv = () } in let pst = prover pst0 in let nts : nts:PS.nt_substs { PS.well_typed_nt_substs pst.pg pst.uvs nts /\ PS.is_permutation nts pst.ss } = let r = PS.ss_to_nt_substs pst.pg pst.uvs pst.ss in match r with | Inr msg -> fail pst.pg None (Printf.sprintf "prover error: ill-typed substitutions (%s)" msg) | Inl nts -> nts in let nts_uvs = PS.well_typed_nt_substs_prefix pst.pg pst.uvs nts uvs in let k : continuation_elaborator g (ctxt * tm_emp) pst.pg ((list_as_vprop pst.remaining_ctxt * tm_emp) * (PS.nt_subst_term pst.solved nts)) = pst.k in // admit () let goals_inv : vprop_equiv (push_env pst.pg pst.uvs) goals (list_as_vprop [] * pst.solved) = pst.goals_inv in let goals_inv : vprop_equiv pst.pg (PS.nt_subst_term goals nts) (PS.nt_subst_term (list_as_vprop [] * pst.solved) nts) = PS.vprop_equiv_nt_substs_derived pst.pg pst.uvs goals_inv nts in // goals is well-typed in initial g + uvs // so any of the remaining uvs in pst.uvs should not be in goals // so we can drop their substitutions from the tail of nts assume (PS.nt_subst_term goals nts == PS.nt_subst_term goals nts_uvs); (| pst.pg, nts_uvs, list_as_vprop pst.remaining_ctxt, k_elab_equiv k (magic ()) (magic ()) |) #pop-options #push-options "--z3rlimit_factor 8 --fuel 0 --ifuel 1 --retry 5" let try_frame_pre_uvs (#g:env) (#ctxt:vprop) (ctxt_typing:tot_typing g ctxt tm_vprop) (uvs:env { disjoint g uvs }) (d:(t:st_term & c:comp_st & st_typing (push_env g uvs) t c)) (res_ppname:ppname) : T.Tac (checker_result_t g ctxt None) = let (| t, c, d |) = d in let g = push_context g "try_frame_pre" t.range in let (| g1, nts, remaining_ctxt, k_frame |) = prove #g #_ ctxt_typing uvs #(comp_pre c) (magic ()) in // assert (nts == []); let d : st_typing (push_env g1 uvs) t c = Metatheory.st_typing_weakening g uvs t c d g1 in assert (comp_pre (PS.nt_subst_comp c nts) == PS.nt_subst_term (comp_pre c) nts); let t = PS.nt_subst_st_term t nts in let c = PS.nt_subst_comp c nts in let d : st_typing g1 t c = PS.st_typing_nt_substs_derived g1 uvs d nts in let k_frame : continuation_elaborator g ctxt g1 (comp_pre c * remaining_ctxt) = coerce_eq k_frame () in let x = fresh g1 in let ty = comp_res c in let g2 = push_binding g1 x res_ppname ty in assert (g2 `env_extends` g1); let ctxt' = (open_term_nv (comp_post c) (res_ppname, x) * remaining_ctxt) in let d : st_typing g1 t c = Metatheory.st_typing_weakening_standard d g1 in let k : continuation_elaborator g1 (remaining_ctxt * comp_pre c) g2 ctxt' = continuation_elaborator_with_bind remaining_ctxt d (magic ()) (res_ppname, x) in let k : continuation_elaborator g1 (comp_pre c * remaining_ctxt) g2 ctxt' = k_elab_equiv k (VE_Comm _ _ _) (VE_Refl _ _) in let k = k_elab_trans k_frame k in let comp_res_typing_in_g1, _, f = Metatheory.st_comp_typing_inversion_cofinite (Metatheory.comp_typing_inversion (Metatheory.st_typing_correctness d)) in let d_ty : universe_of g2 ty (comp_u c) = Metatheory.tot_typing_weakening_single comp_res_typing_in_g1 x (comp_res c) in assume (~ (x `Set.mem` freevars (comp_post c))); let d_post : vprop_typing g2 (open_term_nv (comp_post c) (res_ppname, x)) = f x in // the magic is for the ctxt' typing // see d_post for post typing // then the remaining_ctxt typing should come from the prover state // TODO: add it there // and then ctxt' is just their `*` (| x, g2, (| comp_u c, ty, d_ty |), (| ctxt', magic () |), k |) #pop-options let try_frame_pre (#g:env) (#ctxt:vprop) (ctxt_typing:tot_typing g ctxt tm_vprop) (d:(t:st_term & c:comp_st & st_typing g t c)) (res_ppname:ppname)
false
false
Pulse.Checker.Prover.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val try_frame_pre (#g:env) (#ctxt:vprop) (ctxt_typing:tot_typing g ctxt tm_vprop) (d:(t:st_term & c:comp_st & st_typing g t c)) (res_ppname:ppname) : T.Tac (checker_result_t g ctxt None)
[]
Pulse.Checker.Prover.try_frame_pre
{ "file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
ctxt_typing: Pulse.Typing.tot_typing g ctxt Pulse.Syntax.Base.tm_vprop -> d: FStar.Pervasives.dtuple3 Pulse.Syntax.Base.st_term (fun _ -> Pulse.Syntax.Base.comp_st) (fun t c -> Pulse.Typing.st_typing g t c) -> res_ppname: Pulse.Syntax.Base.ppname -> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g ctxt FStar.Pervasives.Native.None)
{ "end_col": 48, "end_line": 357, "start_col": 42, "start_line": 353 }
FStar.Tactics.Effect.Tac
val prove_pures (#preamble: _) (pst: prover_state preamble) : T.Tac (pst': prover_state preamble {pst' `pst_extends` pst /\ is_terminal pst'})
[ { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroPure", "short_module": "IntroPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroExists", "short_module": "IntroExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Match", "short_module": "Match" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimPure", "short_module": "ElimPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimExists", "short_module": "ElimExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Stubs.Pprint", "short_module": "Pprint" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Base", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec prove_pures #preamble (pst:prover_state preamble) : T.Tac (pst':prover_state preamble { pst' `pst_extends` pst /\ is_terminal pst' }) = match pst.unsolved with | [] -> pst | {t=Tm_Pure p}::unsolved' -> let pst_opt = IntroPure.intro_pure pst p unsolved' () in (match pst_opt with | None -> let open Pulse.PP in fail_doc pst.pg None [ text "Cannot prove pure proposition" ^/^ pp p ] | Some pst1 -> let pst2 = prove_pures pst1 in assert (pst1 `pst_extends` pst); assert (pst2 `pst_extends` pst1); assert (pst2 `pst_extends` pst); pst2) | _ -> fail pst.pg None (Printf.sprintf "Impossible! prover.prove_pures: %s is not a pure, please file a bug-report" (P.term_to_string (L.hd pst.unsolved)))
val prove_pures (#preamble: _) (pst: prover_state preamble) : T.Tac (pst': prover_state preamble {pst' `pst_extends` pst /\ is_terminal pst'}) let rec prove_pures #preamble (pst: prover_state preamble) : T.Tac (pst': prover_state preamble {pst' `pst_extends` pst /\ is_terminal pst'}) =
true
null
false
match pst.unsolved with | [] -> pst | { t = Tm_Pure p } :: unsolved' -> let pst_opt = IntroPure.intro_pure pst p unsolved' () in (match pst_opt with | None -> let open Pulse.PP in fail_doc pst.pg None [text "Cannot prove pure proposition" ^/^ pp p] | Some pst1 -> let pst2 = prove_pures pst1 in assert (pst1 `pst_extends` pst); assert (pst2 `pst_extends` pst1); assert (pst2 `pst_extends` pst); pst2) | _ -> fail pst.pg None (Printf.sprintf "Impossible! prover.prove_pures: %s is not a pure, please file a bug-report" (P.term_to_string (L.hd pst.unsolved)))
{ "checked_file": "Pulse.Checker.Prover.fst.checked", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.PP.fst.checked", "Pulse.Config.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.Match.fsti.checked", "Pulse.Checker.Prover.IntroPure.fsti.checked", "Pulse.Checker.Prover.IntroExists.fsti.checked", "Pulse.Checker.Prover.ElimPure.fsti.checked", "Pulse.Checker.Prover.ElimExists.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Prover.fst" }
[]
[ "Pulse.Checker.Prover.Base.preamble", "Pulse.Checker.Prover.Base.prover_state", "Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__unsolved", "Prims.l_and", "Pulse.Checker.Prover.Base.pst_extends", "Pulse.Checker.Prover.Base.is_terminal", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.range", "Prims.list", "Pulse.Syntax.Base.vprop", "Pulse.Typing.Env.fail_doc", "Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__pg", "FStar.Pervasives.Native.None", "FStar.Stubs.Pprint.document", "Prims.Cons", "Prims.Nil", "FStar.Stubs.Pprint.op_Hat_Slash_Hat", "Pulse.PP.text", "Pulse.PP.pp", "Pulse.PP.uu___44", "Prims.unit", "Prims._assert", "Pulse.Checker.Prover.prove_pures", "FStar.Pervasives.Native.option", "Pulse.Checker.Prover.IntroPure.intro_pure", "Pulse.Typing.Env.fail", "Prims.string", "FStar.Printf.sprintf", "Pulse.Syntax.Printer.term_to_string", "FStar.List.Tot.Base.hd" ]
[]
module Pulse.Checker.Prover open FStar.List.Tot open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Base module L = FStar.List.Tot module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Pprint = FStar.Stubs.Pprint module Metatheory = Pulse.Typing.Metatheory module PS = Pulse.Checker.Prover.Substs module ElimExists = Pulse.Checker.Prover.ElimExists module ElimPure = Pulse.Checker.Prover.ElimPure module Match = Pulse.Checker.Prover.Match module IntroExists = Pulse.Checker.Prover.IntroExists module IntroPure = Pulse.Checker.Prover.IntroPure let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x let unsolved_equiv_pst (#preamble:_) (pst:prover_state preamble) (unsolved':list vprop) (d:vprop_equiv (push_env pst.pg pst.uvs) (list_as_vprop pst.unsolved) (list_as_vprop unsolved')) : prover_state preamble = { pst with unsolved = unsolved'; goals_inv = magic () } let remaining_ctxt_equiv_pst (#preamble:_) (pst:prover_state preamble) (remaining_ctxt':list vprop) (d:vprop_equiv pst.pg (list_as_vprop pst.remaining_ctxt) (list_as_vprop remaining_ctxt')) : prover_state preamble = { pst with remaining_ctxt = remaining_ctxt'; remaining_ctxt_frame_typing = magic (); k = k_elab_equiv pst.k (VE_Refl _ _) (magic ()) } let rec collect_exists (g:env) (l:list vprop) : exs:list vprop & rest:list vprop & vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) = match l with | [] -> (| [], [], VE_Refl _ _ |) | hd::tl -> let (| exs, rest, _ |) = collect_exists g tl in match hd.t with | Tm_ExistsSL _ _ _ -> (| hd::exs, rest, magic () |) | _ -> (| exs, hd::rest, magic () |) let rec collect_pures (g:env) (l:list vprop) : pures:list vprop & rest:list vprop & vprop_equiv g (list_as_vprop l) (list_as_vprop (rest @ pures)) = match l with | [] -> (| [], [], VE_Refl _ _ |) | hd::tl -> let (| pures, rest, _ |) = collect_pures g tl in match hd.t with | Tm_Pure _ -> (| hd::pures, rest, magic () |) | _ -> (| pures, hd::rest, magic () |) let move_hd_end (g:env) (l:list vprop { Cons? l }) : vprop_equiv g (list_as_vprop l) (list_as_vprop (L.tl l @ [L.hd l])) = magic () let rec match_q (#preamble:_) (pst:prover_state preamble) (q:vprop) (unsolved':list vprop) (_:squash (pst.unsolved == q::unsolved')) (i:nat) : T.Tac (option (pst':prover_state preamble { pst' `pst_extends` pst })) = if L.length pst.remaining_ctxt = 0 then None else if i = L.length pst.remaining_ctxt then None else let p = L.hd pst.remaining_ctxt in let pst_opt = Match.match_step pst p (L.tl pst.remaining_ctxt) q unsolved' () in match pst_opt with | Some pst -> Some pst | None -> let pst = remaining_ctxt_equiv_pst pst (L.tl pst.remaining_ctxt @ [L.hd pst.remaining_ctxt]) (move_hd_end pst.pg pst.remaining_ctxt) in match_q pst q unsolved' () (i+1) let rec prove_pures #preamble (pst:prover_state preamble) : T.Tac (pst':prover_state preamble { pst' `pst_extends` pst /\ is_terminal pst' }) =
false
false
Pulse.Checker.Prover.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val prove_pures (#preamble: _) (pst: prover_state preamble) : T.Tac (pst': prover_state preamble {pst' `pst_extends` pst /\ is_terminal pst'})
[ "recursion" ]
Pulse.Checker.Prover.prove_pures
{ "file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
pst: Pulse.Checker.Prover.Base.prover_state preamble -> FStar.Tactics.Effect.Tac (pst': Pulse.Checker.Prover.Base.prover_state preamble { Pulse.Checker.Prover.Base.pst_extends pst' pst /\ Pulse.Checker.Prover.Base.is_terminal pst' })
{ "end_col": 48, "end_line": 113, "start_col": 2, "start_line": 93 }
FStar.Tactics.Effect.Tac
val match_q: #preamble: _ -> pst: prover_state preamble -> q: vprop -> unsolved': list vprop -> squash (pst.unsolved == q :: unsolved') -> i: nat -> T.Tac (option (pst': prover_state preamble {pst' `pst_extends` pst}))
[ { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroPure", "short_module": "IntroPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroExists", "short_module": "IntroExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Match", "short_module": "Match" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimPure", "short_module": "ElimPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimExists", "short_module": "ElimExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Stubs.Pprint", "short_module": "Pprint" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Base", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec match_q (#preamble:_) (pst:prover_state preamble) (q:vprop) (unsolved':list vprop) (_:squash (pst.unsolved == q::unsolved')) (i:nat) : T.Tac (option (pst':prover_state preamble { pst' `pst_extends` pst })) = if L.length pst.remaining_ctxt = 0 then None else if i = L.length pst.remaining_ctxt then None else let p = L.hd pst.remaining_ctxt in let pst_opt = Match.match_step pst p (L.tl pst.remaining_ctxt) q unsolved' () in match pst_opt with | Some pst -> Some pst | None -> let pst = remaining_ctxt_equiv_pst pst (L.tl pst.remaining_ctxt @ [L.hd pst.remaining_ctxt]) (move_hd_end pst.pg pst.remaining_ctxt) in match_q pst q unsolved' () (i+1)
val match_q: #preamble: _ -> pst: prover_state preamble -> q: vprop -> unsolved': list vprop -> squash (pst.unsolved == q :: unsolved') -> i: nat -> T.Tac (option (pst': prover_state preamble {pst' `pst_extends` pst})) let rec match_q (#preamble: _) (pst: prover_state preamble) (q: vprop) (unsolved': list vprop) (_: squash (pst.unsolved == q :: unsolved')) (i: nat) : T.Tac (option (pst': prover_state preamble {pst' `pst_extends` pst})) =
false
null
false
if L.length pst.remaining_ctxt = 0 then None else if i = L.length pst.remaining_ctxt then None else let p = L.hd pst.remaining_ctxt in let pst_opt = Match.match_step pst p (L.tl pst.remaining_ctxt) q unsolved' () in match pst_opt with | Some pst -> Some pst | None -> let pst = remaining_ctxt_equiv_pst pst (L.tl pst.remaining_ctxt @ [L.hd pst.remaining_ctxt]) (move_hd_end pst.pg pst.remaining_ctxt) in match_q pst q unsolved' () (i + 1)
{ "checked_file": "Pulse.Checker.Prover.fst.checked", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.PP.fst.checked", "Pulse.Config.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.Match.fsti.checked", "Pulse.Checker.Prover.IntroPure.fsti.checked", "Pulse.Checker.Prover.IntroExists.fsti.checked", "Pulse.Checker.Prover.ElimPure.fsti.checked", "Pulse.Checker.Prover.ElimExists.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Prover.fst" }
[]
[ "Pulse.Checker.Prover.Base.preamble", "Pulse.Checker.Prover.Base.prover_state", "Pulse.Syntax.Base.vprop", "Prims.list", "Prims.squash", "Prims.eq2", "Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__unsolved", "Prims.Cons", "Prims.nat", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__remaining_ctxt", "FStar.Pervasives.Native.None", "Pulse.Checker.Prover.Base.pst_extends", "FStar.Pervasives.Native.option", "Prims.bool", "FStar.Pervasives.Native.Some", "Pulse.Checker.Prover.match_q", "Prims.op_Addition", "Pulse.Checker.Prover.remaining_ctxt_equiv_pst", "FStar.List.Tot.Base.op_At", "FStar.List.Tot.Base.tl", "FStar.List.Tot.Base.hd", "Prims.Nil", "Pulse.Checker.Prover.move_hd_end", "Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__pg", "Pulse.Checker.Prover.Match.match_step" ]
[]
module Pulse.Checker.Prover open FStar.List.Tot open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Base module L = FStar.List.Tot module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Pprint = FStar.Stubs.Pprint module Metatheory = Pulse.Typing.Metatheory module PS = Pulse.Checker.Prover.Substs module ElimExists = Pulse.Checker.Prover.ElimExists module ElimPure = Pulse.Checker.Prover.ElimPure module Match = Pulse.Checker.Prover.Match module IntroExists = Pulse.Checker.Prover.IntroExists module IntroPure = Pulse.Checker.Prover.IntroPure let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x let unsolved_equiv_pst (#preamble:_) (pst:prover_state preamble) (unsolved':list vprop) (d:vprop_equiv (push_env pst.pg pst.uvs) (list_as_vprop pst.unsolved) (list_as_vprop unsolved')) : prover_state preamble = { pst with unsolved = unsolved'; goals_inv = magic () } let remaining_ctxt_equiv_pst (#preamble:_) (pst:prover_state preamble) (remaining_ctxt':list vprop) (d:vprop_equiv pst.pg (list_as_vprop pst.remaining_ctxt) (list_as_vprop remaining_ctxt')) : prover_state preamble = { pst with remaining_ctxt = remaining_ctxt'; remaining_ctxt_frame_typing = magic (); k = k_elab_equiv pst.k (VE_Refl _ _) (magic ()) } let rec collect_exists (g:env) (l:list vprop) : exs:list vprop & rest:list vprop & vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) = match l with | [] -> (| [], [], VE_Refl _ _ |) | hd::tl -> let (| exs, rest, _ |) = collect_exists g tl in match hd.t with | Tm_ExistsSL _ _ _ -> (| hd::exs, rest, magic () |) | _ -> (| exs, hd::rest, magic () |) let rec collect_pures (g:env) (l:list vprop) : pures:list vprop & rest:list vprop & vprop_equiv g (list_as_vprop l) (list_as_vprop (rest @ pures)) = match l with | [] -> (| [], [], VE_Refl _ _ |) | hd::tl -> let (| pures, rest, _ |) = collect_pures g tl in match hd.t with | Tm_Pure _ -> (| hd::pures, rest, magic () |) | _ -> (| pures, hd::rest, magic () |) let move_hd_end (g:env) (l:list vprop { Cons? l }) : vprop_equiv g (list_as_vprop l) (list_as_vprop (L.tl l @ [L.hd l])) = magic () let rec match_q (#preamble:_) (pst:prover_state preamble) (q:vprop) (unsolved':list vprop) (_:squash (pst.unsolved == q::unsolved')) (i:nat) : T.Tac (option (pst':prover_state preamble { pst' `pst_extends` pst })) =
false
false
Pulse.Checker.Prover.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val match_q: #preamble: _ -> pst: prover_state preamble -> q: vprop -> unsolved': list vprop -> squash (pst.unsolved == q :: unsolved') -> i: nat -> T.Tac (option (pst': prover_state preamble {pst' `pst_extends` pst}))
[ "recursion" ]
Pulse.Checker.Prover.match_q
{ "file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
pst: Pulse.Checker.Prover.Base.prover_state preamble -> q: Pulse.Syntax.Base.vprop -> unsolved': Prims.list Pulse.Syntax.Base.vprop -> _: Prims.squash (Mkprover_state?.unsolved pst == q :: unsolved') -> i: Prims.nat -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option (pst': Pulse.Checker.Prover.Base.prover_state preamble {Pulse.Checker.Prover.Base.pst_extends pst' pst}))
{ "end_col": 38, "end_line": 87, "start_col": 2, "start_line": 73 }
FStar.Tactics.Effect.Tac
val prover (#preamble: _) (pst0: prover_state preamble) : T.Tac (pst': prover_state preamble {pst' `pst_extends` pst0 /\ is_terminal pst'})
[ { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroPure", "short_module": "IntroPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.IntroExists", "short_module": "IntroExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Match", "short_module": "Match" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimPure", "short_module": "ElimPure" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.ElimExists", "short_module": "ElimExists" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Stubs.Pprint", "short_module": "Pprint" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Prover.Base", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec prover (#preamble:_) (pst0:prover_state preamble) : T.Tac (pst':prover_state preamble { pst' `pst_extends` pst0 /\ is_terminal pst' }) = debug_prover pst0.pg (fun _ -> Printf.sprintf "At the prover top-level with remaining_ctxt: %s\nunsolved: %s" (P.term_to_string (list_as_vprop pst0.remaining_ctxt)) (P.term_to_string (list_as_vprop pst0.unsolved))); match pst0.unsolved with | [] -> pst0 | _ -> let pst = ElimExists.elim_exists_pst pst0 in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: remaining_ctxt after elim exists: %s\n" (P.term_to_string (list_as_vprop pst.remaining_ctxt))); let pst = ElimPure.elim_pure_pst pst in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: remaining_ctxt after elim pure: %s\n" (P.term_to_string (list_as_vprop pst.remaining_ctxt))); let (| exs, rest, d |) = collect_exists (push_env pst.pg pst.uvs) pst.unsolved in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: tried to pull exists: exs: %s and rest: %s\n" (P.term_to_string (list_as_vprop exs)) (P.term_to_string (list_as_vprop rest))); let pst = unsolved_equiv_pst pst (exs@rest) d in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: unsolved after pulling exists at the top: %s\n" (P.term_to_string (list_as_vprop pst.unsolved))); match pst.unsolved with | {t=Tm_ExistsSL u b body}::unsolved' -> IntroExists.intro_exists pst u b body unsolved' () prover | _ -> let (| pures, rest, d |) = collect_pures (push_env pst.pg pst.uvs) pst.unsolved in let pst = unsolved_equiv_pst pst (rest@pures) d in match pst.unsolved with | {t=Tm_Pure _}::tl -> prove_pures pst | q::tl -> let pst_opt = match_q pst q tl () 0 in match pst_opt with | None -> let open Pprint in let open Pulse.PP in let msg = [ text "Error in proving precondition"; text "Cannot prove:" ^^ indent (pp q); text "In the context:" ^^ indent (pp (list_as_vprop pst.remaining_ctxt)) ] @ (if Pulse.Config.debug_flag "initial_solver_state" then [ text "The prover was started with goal:" ^^ indent (pp preamble.goals); text "and initial context:" ^^ indent (pp preamble.ctxt); ] else []) in // GM: I feel I should use (Some q.range) instead of None, but that makes // several error locations worse. fail_doc pst.pg None msg | Some pst -> prover pst
val prover (#preamble: _) (pst0: prover_state preamble) : T.Tac (pst': prover_state preamble {pst' `pst_extends` pst0 /\ is_terminal pst'}) let rec prover (#preamble: _) (pst0: prover_state preamble) : T.Tac (pst': prover_state preamble {pst' `pst_extends` pst0 /\ is_terminal pst'}) =
true
null
false
debug_prover pst0.pg (fun _ -> Printf.sprintf "At the prover top-level with remaining_ctxt: %s\nunsolved: %s" (P.term_to_string (list_as_vprop pst0.remaining_ctxt)) (P.term_to_string (list_as_vprop pst0.unsolved))); match pst0.unsolved with | [] -> pst0 | _ -> let pst = ElimExists.elim_exists_pst pst0 in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: remaining_ctxt after elim exists: %s\n" (P.term_to_string (list_as_vprop pst.remaining_ctxt))); let pst = ElimPure.elim_pure_pst pst in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: remaining_ctxt after elim pure: %s\n" (P.term_to_string (list_as_vprop pst.remaining_ctxt))); let (| exs , rest , d |) = collect_exists (push_env pst.pg pst.uvs) pst.unsolved in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: tried to pull exists: exs: %s and rest: %s\n" (P.term_to_string (list_as_vprop exs)) (P.term_to_string (list_as_vprop rest))); let pst = unsolved_equiv_pst pst (exs @ rest) d in debug_prover pst.pg (fun _ -> Printf.sprintf "prover: unsolved after pulling exists at the top: %s\n" (P.term_to_string (list_as_vprop pst.unsolved))); match pst.unsolved with | { t = Tm_ExistsSL u b body } :: unsolved' -> IntroExists.intro_exists pst u b body unsolved' () prover | _ -> let (| pures , rest , d |) = collect_pures (push_env pst.pg pst.uvs) pst.unsolved in let pst = unsolved_equiv_pst pst (rest @ pures) d in match pst.unsolved with | { t = Tm_Pure _ } :: tl -> prove_pures pst | q :: tl -> let pst_opt = match_q pst q tl () 0 in match pst_opt with | None -> let open Pprint in let open Pulse.PP in let msg = [ text "Error in proving precondition"; text "Cannot prove:" ^^ indent (pp q); text "In the context:" ^^ indent (pp (list_as_vprop pst.remaining_ctxt)) ] @ (if Pulse.Config.debug_flag "initial_solver_state" then [ text "The prover was started with goal:" ^^ indent (pp preamble.goals); text "and initial context:" ^^ indent (pp preamble.ctxt) ] else []) in fail_doc pst.pg None msg | Some pst -> prover pst
{ "checked_file": "Pulse.Checker.Prover.fst.checked", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.PP.fst.checked", "Pulse.Config.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.Match.fsti.checked", "Pulse.Checker.Prover.IntroPure.fsti.checked", "Pulse.Checker.Prover.IntroExists.fsti.checked", "Pulse.Checker.Prover.ElimPure.fsti.checked", "Pulse.Checker.Prover.ElimExists.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Prover.fst" }
[]
[ "Pulse.Checker.Prover.Base.preamble", "Pulse.Checker.Prover.Base.prover_state", "Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__unsolved", "Prims.l_and", "Pulse.Checker.Prover.Base.pst_extends", "Pulse.Checker.Prover.Base.is_terminal", "Prims.list", "Pulse.Syntax.Base.vprop", "Pulse.Typing.vprop_equiv", "Pulse.Typing.Env.push_env", "Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__pg", "Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__uvs", "Pulse.Typing.Combinators.list_as_vprop", "FStar.List.Tot.Base.op_At", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.binder", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.range", "Pulse.Checker.Prover.IntroExists.intro_exists", "Pulse.Checker.Prover.prover", "Pulse.Checker.Prover.prove_pures", "Pulse.Typing.Env.fail_doc", "FStar.Pervasives.Native.None", "FStar.Stubs.Pprint.document", "Prims.Cons", "Prims.Nil", "FStar.Stubs.Pprint.op_Hat_Hat", "Pulse.PP.text", "Pulse.PP.indent", "Pulse.PP.pp", "Pulse.PP.uu___44", "Pulse.Checker.Prover.Base.__proj__Mkpreamble__item__ctxt", "Pulse.Checker.Prover.Base.__proj__Mkpreamble__item__goals", "Prims.bool", "Pulse.Config.debug_flag", "Pulse.Checker.Prover.Base.__proj__Mkprover_state__item__remaining_ctxt", "FStar.Pervasives.Native.option", "Pulse.Checker.Prover.match_q", "Pulse.Checker.Prover.unsolved_equiv_pst", "FStar.Pervasives.dtuple3", "Pulse.Checker.Prover.collect_pures", "Prims.unit", "Pulse.Checker.Prover.Util.debug_prover", "FStar.Printf.sprintf", "Prims.string", "Pulse.Syntax.Printer.term_to_string", "Pulse.Checker.Prover.collect_exists", "Prims.eq2", "Pulse.Checker.Prover.ElimPure.elim_pure_pst", "Pulse.Checker.Prover.ElimExists.elim_exists_pst" ]
[]
module Pulse.Checker.Prover open FStar.List.Tot open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Base module L = FStar.List.Tot module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Pprint = FStar.Stubs.Pprint module Metatheory = Pulse.Typing.Metatheory module PS = Pulse.Checker.Prover.Substs module ElimExists = Pulse.Checker.Prover.ElimExists module ElimPure = Pulse.Checker.Prover.ElimPure module Match = Pulse.Checker.Prover.Match module IntroExists = Pulse.Checker.Prover.IntroExists module IntroPure = Pulse.Checker.Prover.IntroPure let coerce_eq (#a #b:Type) (x:a) (_:squash (a == b)) : y:b{y == x} = x let unsolved_equiv_pst (#preamble:_) (pst:prover_state preamble) (unsolved':list vprop) (d:vprop_equiv (push_env pst.pg pst.uvs) (list_as_vprop pst.unsolved) (list_as_vprop unsolved')) : prover_state preamble = { pst with unsolved = unsolved'; goals_inv = magic () } let remaining_ctxt_equiv_pst (#preamble:_) (pst:prover_state preamble) (remaining_ctxt':list vprop) (d:vprop_equiv pst.pg (list_as_vprop pst.remaining_ctxt) (list_as_vprop remaining_ctxt')) : prover_state preamble = { pst with remaining_ctxt = remaining_ctxt'; remaining_ctxt_frame_typing = magic (); k = k_elab_equiv pst.k (VE_Refl _ _) (magic ()) } let rec collect_exists (g:env) (l:list vprop) : exs:list vprop & rest:list vprop & vprop_equiv g (list_as_vprop l) (list_as_vprop (exs @ rest)) = match l with | [] -> (| [], [], VE_Refl _ _ |) | hd::tl -> let (| exs, rest, _ |) = collect_exists g tl in match hd.t with | Tm_ExistsSL _ _ _ -> (| hd::exs, rest, magic () |) | _ -> (| exs, hd::rest, magic () |) let rec collect_pures (g:env) (l:list vprop) : pures:list vprop & rest:list vprop & vprop_equiv g (list_as_vprop l) (list_as_vprop (rest @ pures)) = match l with | [] -> (| [], [], VE_Refl _ _ |) | hd::tl -> let (| pures, rest, _ |) = collect_pures g tl in match hd.t with | Tm_Pure _ -> (| hd::pures, rest, magic () |) | _ -> (| pures, hd::rest, magic () |) let move_hd_end (g:env) (l:list vprop { Cons? l }) : vprop_equiv g (list_as_vprop l) (list_as_vprop (L.tl l @ [L.hd l])) = magic () let rec match_q (#preamble:_) (pst:prover_state preamble) (q:vprop) (unsolved':list vprop) (_:squash (pst.unsolved == q::unsolved')) (i:nat) : T.Tac (option (pst':prover_state preamble { pst' `pst_extends` pst })) = if L.length pst.remaining_ctxt = 0 then None else if i = L.length pst.remaining_ctxt then None else let p = L.hd pst.remaining_ctxt in let pst_opt = Match.match_step pst p (L.tl pst.remaining_ctxt) q unsolved' () in match pst_opt with | Some pst -> Some pst | None -> let pst = remaining_ctxt_equiv_pst pst (L.tl pst.remaining_ctxt @ [L.hd pst.remaining_ctxt]) (move_hd_end pst.pg pst.remaining_ctxt) in match_q pst q unsolved' () (i+1) let rec prove_pures #preamble (pst:prover_state preamble) : T.Tac (pst':prover_state preamble { pst' `pst_extends` pst /\ is_terminal pst' }) = match pst.unsolved with | [] -> pst | {t=Tm_Pure p}::unsolved' -> let pst_opt = IntroPure.intro_pure pst p unsolved' () in (match pst_opt with | None -> let open Pulse.PP in fail_doc pst.pg None [ text "Cannot prove pure proposition" ^/^ pp p ] | Some pst1 -> let pst2 = prove_pures pst1 in assert (pst1 `pst_extends` pst); assert (pst2 `pst_extends` pst1); assert (pst2 `pst_extends` pst); pst2) | _ -> fail pst.pg None (Printf.sprintf "Impossible! prover.prove_pures: %s is not a pure, please file a bug-report" (P.term_to_string (L.hd pst.unsolved))) #push-options "--z3rlimit_factor 4" let rec prover (#preamble:_) (pst0:prover_state preamble) : T.Tac (pst':prover_state preamble { pst' `pst_extends` pst0 /\ is_terminal pst' }) =
false
false
Pulse.Checker.Prover.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val prover (#preamble: _) (pst0: prover_state preamble) : T.Tac (pst': prover_state preamble {pst' `pst_extends` pst0 /\ is_terminal pst'})
[ "recursion" ]
Pulse.Checker.Prover.prover
{ "file_name": "lib/steel/pulse/Pulse.Checker.Prover.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
pst0: Pulse.Checker.Prover.Base.prover_state preamble -> FStar.Tactics.Effect.Tac (pst': Pulse.Checker.Prover.Base.prover_state preamble { Pulse.Checker.Prover.Base.pst_extends pst' pst0 /\ Pulse.Checker.Prover.Base.is_terminal pst' })
{ "end_col": 32, "end_line": 184, "start_col": 2, "start_line": 122 }
Prims.Tot
val array_domain (n: Ghost.erased SZ.t) : Tot eqtype
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let array_domain (n: Ghost.erased SZ.t) : Tot eqtype = (i: SZ.t { SZ.v i < SZ.v n })
val array_domain (n: Ghost.erased SZ.t) : Tot eqtype let array_domain (n: Ghost.erased SZ.t) : Tot eqtype =
false
null
false
(i: SZ.t{SZ.v i < SZ.v n})
{ "checked_file": "Steel.ST.C.Types.Array.Base.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.C.Types.Array.Base.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.SizeT.t", "Prims.b2t", "Prims.op_LessThan", "FStar.SizeT.v", "FStar.Ghost.reveal", "Prims.eqtype" ]
[]
module Steel.ST.C.Types.Array.Base module SZ = FStar.SizeT inline_for_extraction let array_domain (n: Ghost.erased SZ.t)
false
true
Steel.ST.C.Types.Array.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val array_domain (n: Ghost.erased SZ.t) : Tot eqtype
[]
Steel.ST.C.Types.Array.Base.array_domain
{ "file_name": "lib/steel/c/Steel.ST.C.Types.Array.Base.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.Ghost.erased FStar.SizeT.t -> Prims.eqtype
{ "end_col": 31, "end_line": 8, "start_col": 2, "start_line": 8 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let params_nbar = 8ul
let params_nbar =
false
null
false
8ul
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val params_nbar : FStar.UInt32.t
[]
Hacl.Impl.Frodo.Params.params_nbar
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.UInt32.t
{ "end_col": 21, "end_line": 48, "start_col": 18, "start_line": 48 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a
let bytes_pkhash (a: S.frodo_alg) =
false
null
false
crypto_bytes a
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.Impl.Frodo.Params.crypto_bytes", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Lib.IntTypes.v", "Spec.Frodo.Params.crypto_bytes" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bytes_pkhash : a: Spec.Frodo.Params.frodo_alg -> x: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v x == Spec.Frodo.Params.crypto_bytes a}
[]
Hacl.Impl.Frodo.Params.bytes_pkhash
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> x: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v x == Spec.Frodo.Params.crypto_bytes a}
{ "end_col": 16, "end_line": 55, "start_col": 2, "start_line": 55 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bytes_seed_a = 16ul
let bytes_seed_a =
false
null
false
16ul
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bytes_seed_a : FStar.UInt32.t
[]
Hacl.Impl.Frodo.Params.bytes_seed_a
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.UInt32.t
{ "end_col": 23, "end_line": 51, "start_col": 19, "start_line": 51 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let is_supported (a:S.frodo_gen_a) = match a with | S.SHAKE128 -> true | S.AES128 -> false
let is_supported (a: S.frodo_gen_a) =
false
null
false
match a with | S.SHAKE128 -> true | S.AES128 -> false
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_gen_a", "Prims.bool" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a inline_for_extraction noextract let frodo_shake_st (a:S.frodo_alg) = inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> outputByteLen:size_t -> output:lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) inline_for_extraction noextract let frodo_shake (a:S.frodo_alg) : frodo_shake_st a = match a with | S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl | S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl inline_for_extraction noextract
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_supported : a: Spec.Frodo.Params.frodo_gen_a -> Prims.bool
[]
Hacl.Impl.Frodo.Params.is_supported
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_gen_a -> Prims.bool
{ "end_col": 21, "end_line": 114, "start_col": 2, "start_line": 112 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a
let crypto_publickeybytes (a: S.frodo_alg) =
false
null
false
bytes_seed_a +! publicmatrixbytes_len a
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.bytes_seed_a", "Hacl.Impl.Frodo.Params.publicmatrixbytes_len", "Lib.IntTypes.int_t" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_publickeybytes : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
[]
Hacl.Impl.Frodo.Params.crypto_publickeybytes
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{ "end_col": 41, "end_line": 79, "start_col": 2, "start_line": 79 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_shake_st (a:S.frodo_alg) = inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> outputByteLen:size_t -> output:lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen))
let frodo_shake_st (a: S.frodo_alg) =
false
null
false
inputByteLen: size_t -> input: lbuffer uint8 inputByteLen -> outputByteLen: size_t -> output: lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen))
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Spec.Frodo.Params.frodo_shake" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a inline_for_extraction noextract
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_shake_st : a: Spec.Frodo.Params.frodo_alg -> Type0
[]
Hacl.Impl.Frodo.Params.frodo_shake_st
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> Type0
{ "end_col": 95, "end_line": 100, "start_col": 4, "start_line": 92 }
Prims.Tot
val frodo_shake (a: S.frodo_alg) : frodo_shake_st a
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_shake (a:S.frodo_alg) : frodo_shake_st a = match a with | S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl | S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl
val frodo_shake (a: S.frodo_alg) : frodo_shake_st a let frodo_shake (a: S.frodo_alg) : frodo_shake_st a =
false
null
false
match a with | S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl | S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.SHA3.shake128_hacl", "Hacl.SHA3.shake256_hacl", "Hacl.Impl.Frodo.Params.frodo_shake_st" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a inline_for_extraction noextract let frodo_shake_st (a:S.frodo_alg) = inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> outputByteLen:size_t -> output:lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) inline_for_extraction noextract
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_shake (a: S.frodo_alg) : frodo_shake_st a
[]
Hacl.Impl.Frodo.Params.frodo_shake
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> Hacl.Impl.Frodo.Params.frodo_shake_st a
{ "end_col": 55, "end_line": 107, "start_col": 2, "start_line": 105 }
Prims.Tot
val params_extracted_bits (a: S.frodo_alg) : x: size_t{v x == S.params_extracted_bits a}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul
val params_extracted_bits (a: S.frodo_alg) : x: size_t{v x == S.params_extracted_bits a} let params_extracted_bits (a: S.frodo_alg) : x: size_t{v x == S.params_extracted_bits a} =
false
null
false
match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Prims.op_LessThan", "Spec.Frodo.Params.params_logq", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.Frodo.Params.params_extracted_bits" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val params_extracted_bits (a: S.frodo_alg) : x: size_t{v x == S.params_extracted_bits a}
[]
Hacl.Impl.Frodo.Params.params_extracted_bits
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.params_extracted_bits a}
{ "end_col": 22, "end_line": 36, "start_col": 2, "start_line": 33 }
Prims.Tot
val cdf_table_len (a: S.frodo_alg) : x: size_t{v x = S.cdf_table_len a}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cdf_table_len (a:S.frodo_alg) : x:size_t{v x = S.cdf_table_len a} = allow_inversion S.frodo_alg; match a with | S.Frodo64 | S.Frodo640 -> 13ul | S.Frodo976 -> 11ul | S.Frodo1344 -> 7ul
val cdf_table_len (a: S.frodo_alg) : x: size_t{v x = S.cdf_table_len a} let cdf_table_len (a: S.frodo_alg) : x: size_t{v x = S.cdf_table_len a} =
false
null
false
allow_inversion S.frodo_alg; match a with | S.Frodo64 | S.Frodo640 -> 13ul | S.Frodo976 -> 11ul | S.Frodo1344 -> 7ul
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.l_and", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.Frodo.Params.cdf_table_len", "Prims.unit", "FStar.Pervasives.allow_inversion" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a inline_for_extraction noextract let frodo_shake_st (a:S.frodo_alg) = inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> outputByteLen:size_t -> output:lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) inline_for_extraction noextract let frodo_shake (a:S.frodo_alg) : frodo_shake_st a = match a with | S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl | S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl inline_for_extraction noextract let is_supported (a:S.frodo_gen_a) = match a with | S.SHAKE128 -> true | S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *) val frodo_gen_matrix: a:S.frodo_gen_a{is_supported a} -> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0} -> seed:lbuffer uint8 16ul -> a_matrix:matrix_t n n -> Stack unit (requires fun h -> live h seed /\ live h a_matrix /\ disjoint seed a_matrix) (ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\ as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) [@CInline] let frodo_gen_matrix a n seed a_matrix = match a with | S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix (* | S.AES128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_aes n seed a_matrix *) (** CDF tables *) let cdf_table640 :x:glbuffer uint16 13ul{witnessed x (S.cdf_table S.Frodo640) /\ recallable x} = createL_global S.cdf_list_640 let cdf_table976 :x:glbuffer uint16 11ul{witnessed x (S.cdf_table S.Frodo976) /\ recallable x} = createL_global S.cdf_list_976 let cdf_table1344 :x:glbuffer uint16 7ul{witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} = createL_global S.cdf_list_1344 inline_for_extraction noextract
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cdf_table_len (a: S.frodo_alg) : x: size_t{v x = S.cdf_table_len a}
[]
Hacl.Impl.Frodo.Params.cdf_table_len
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> x: Lib.IntTypes.size_t{Lib.IntTypes.v x = Spec.Frodo.Params.cdf_table_len a}
{ "end_col": 22, "end_line": 153, "start_col": 2, "start_line": 149 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul)
let ct2bytes_len (a: S.frodo_alg) =
false
null
false
params_logq a *! (params_nbar *! params_nbar /. 8ul)
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.params_logq", "Lib.IntTypes.op_Slash_Dot", "Hacl.Impl.Frodo.Params.params_nbar", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.int_t" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ct2bytes_len : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
[]
Hacl.Impl.Frodo.Params.ct2bytes_len
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{ "end_col": 54, "end_line": 75, "start_col": 2, "start_line": 75 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar
let secretmatrixbytes_len (a: S.frodo_alg) =
false
null
false
2ul *! params_n a *! params_nbar
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Frodo.Params.params_n", "Hacl.Impl.Frodo.Params.params_nbar", "Lib.IntTypes.int_t" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val secretmatrixbytes_len : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
[]
Hacl.Impl.Frodo.Params.secretmatrixbytes_len
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{ "end_col": 34, "end_line": 67, "start_col": 2, "start_line": 67 }
Prims.Tot
val crypto_bytes (a: S.frodo_alg) : x: size_t{v x == S.crypto_bytes a}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul
val crypto_bytes (a: S.frodo_alg) : x: size_t{v x == S.crypto_bytes a} let crypto_bytes (a: S.frodo_alg) : x: size_t{v x == S.crypto_bytes a} =
false
null
false
match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.Frodo.Params.crypto_bytes" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_bytes (a: S.frodo_alg) : x: size_t{v x == S.crypto_bytes a}
[]
Hacl.Impl.Frodo.Params.crypto_bytes
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.crypto_bytes a}
{ "end_col": 23, "end_line": 44, "start_col": 2, "start_line": 41 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul)
let publicmatrixbytes_len (a: S.frodo_alg) =
false
null
false
params_logq a *! (params_n a *! params_nbar /. 8ul)
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.params_logq", "Lib.IntTypes.op_Slash_Dot", "Hacl.Impl.Frodo.Params.params_n", "Hacl.Impl.Frodo.Params.params_nbar", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.int_t" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val publicmatrixbytes_len : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
[]
Hacl.Impl.Frodo.Params.publicmatrixbytes_len
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{ "end_col": 53, "end_line": 63, "start_col": 2, "start_line": 63 }
Prims.Tot
val params_logq (a: S.frodo_alg) : x: size_t{v x == S.params_logq a}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul
val params_logq (a: S.frodo_alg) : x: size_t{v x == S.params_logq a} let params_logq (a: S.frodo_alg) : x: size_t{v x == S.params_logq a} =
false
null
false
match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.Frodo.Params.params_logq" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val params_logq (a: S.frodo_alg) : x: size_t{v x == S.params_logq a}
[]
Hacl.Impl.Frodo.Params.params_logq
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.params_logq a}
{ "end_col": 36, "end_line": 28, "start_col": 2, "start_line": 26 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a
let crypto_ciphertextbytes (a: S.frodo_alg) =
false
null
false
ct1bytes_len a +! ct2bytes_len a
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.ct1bytes_len", "Hacl.Impl.Frodo.Params.ct2bytes_len", "Lib.IntTypes.int_t" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_ciphertextbytes : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
[]
Hacl.Impl.Frodo.Params.crypto_ciphertextbytes
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{ "end_col": 34, "end_line": 87, "start_col": 2, "start_line": 87 }
Prims.Tot
val params_n (a: S.frodo_alg) : x: size_t{v x == S.params_n a}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul
val params_n (a: S.frodo_alg) : x: size_t{v x == S.params_n a} let params_n (a: S.frodo_alg) : x: size_t{v x == S.params_n a} =
false
null
false
match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Prims.op_Equality", "Prims.op_Modulus", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.Frodo.Params.params_n" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val params_n (a: S.frodo_alg) : x: size_t{v x == S.params_n a}
[]
Hacl.Impl.Frodo.Params.params_n
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.params_n a}
{ "end_col": 25, "end_line": 21, "start_col": 2, "start_line": 17 }
Prims.Tot
val cdf_table976:x: glbuffer uint16 11ul {witnessed x (S.cdf_table S.Frodo976) /\ recallable x}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cdf_table976 :x:glbuffer uint16 11ul{witnessed x (S.cdf_table S.Frodo976) /\ recallable x} = createL_global S.cdf_list_976
val cdf_table976:x: glbuffer uint16 11ul {witnessed x (S.cdf_table S.Frodo976) /\ recallable x} let cdf_table976:x: glbuffer uint16 11ul {witnessed x (S.cdf_table S.Frodo976) /\ recallable x} =
false
null
false
createL_global S.cdf_list_976
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Spec.Frodo.Params.cdf_list_976", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a inline_for_extraction noextract let frodo_shake_st (a:S.frodo_alg) = inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> outputByteLen:size_t -> output:lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) inline_for_extraction noextract let frodo_shake (a:S.frodo_alg) : frodo_shake_st a = match a with | S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl | S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl inline_for_extraction noextract let is_supported (a:S.frodo_gen_a) = match a with | S.SHAKE128 -> true | S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *) val frodo_gen_matrix: a:S.frodo_gen_a{is_supported a} -> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0} -> seed:lbuffer uint8 16ul -> a_matrix:matrix_t n n -> Stack unit (requires fun h -> live h seed /\ live h a_matrix /\ disjoint seed a_matrix) (ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\ as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) [@CInline] let frodo_gen_matrix a n seed a_matrix = match a with | S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix (* | S.AES128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_aes n seed a_matrix *) (** CDF tables *) let cdf_table640 :x:glbuffer uint16 13ul{witnessed x (S.cdf_table S.Frodo640) /\ recallable x} = createL_global S.cdf_list_640
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cdf_table976:x: glbuffer uint16 11ul {witnessed x (S.cdf_table S.Frodo976) /\ recallable x}
[]
Hacl.Impl.Frodo.Params.cdf_table976
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: (c: Lib.Buffer.lbuffer_t Lib.Buffer.CONST (Lib.IntTypes.int_t Lib.IntTypes.U16 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 11 <: FStar.UInt32.t) {LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE}) { Lib.Buffer.witnessed x (Spec.Frodo.Params.cdf_table Spec.Frodo.Params.Frodo976) /\ Lib.Buffer.recallable x }
{ "end_col": 31, "end_line": 141, "start_col": 2, "start_line": 141 }
FStar.HyperStack.ST.Stack
val frodo_gen_matrix: a:S.frodo_gen_a{is_supported a} -> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0} -> seed:lbuffer uint8 16ul -> a_matrix:matrix_t n n -> Stack unit (requires fun h -> live h seed /\ live h a_matrix /\ disjoint seed a_matrix) (ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\ as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed))
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_gen_matrix a n seed a_matrix = match a with | S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix
val frodo_gen_matrix: a:S.frodo_gen_a{is_supported a} -> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0} -> seed:lbuffer uint8 16ul -> a_matrix:matrix_t n n -> Stack unit (requires fun h -> live h seed /\ live h a_matrix /\ disjoint seed a_matrix) (ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\ as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) let frodo_gen_matrix a n seed a_matrix =
true
null
false
match a with | S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[]
[ "Spec.Frodo.Params.frodo_gen_a", "Prims.b2t", "Hacl.Impl.Frodo.Params.is_supported", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.IntTypes.maxint", "Lib.IntTypes.U16", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x", "Prims.unit" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a inline_for_extraction noextract let frodo_shake_st (a:S.frodo_alg) = inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> outputByteLen:size_t -> output:lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) inline_for_extraction noextract let frodo_shake (a:S.frodo_alg) : frodo_shake_st a = match a with | S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl | S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl inline_for_extraction noextract let is_supported (a:S.frodo_gen_a) = match a with | S.SHAKE128 -> true | S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *) val frodo_gen_matrix: a:S.frodo_gen_a{is_supported a} -> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0} -> seed:lbuffer uint8 16ul -> a_matrix:matrix_t n n -> Stack unit (requires fun h -> live h seed /\ live h a_matrix /\ disjoint seed a_matrix) (ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\ as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) [@CInline]
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_gen_matrix: a:S.frodo_gen_a{is_supported a} -> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0} -> seed:lbuffer uint8 16ul -> a_matrix:matrix_t n n -> Stack unit (requires fun h -> live h seed /\ live h a_matrix /\ disjoint seed a_matrix) (ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\ as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed))
[]
Hacl.Impl.Frodo.Params.frodo_gen_matrix
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported a} -> n: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v n /\ Lib.IntTypes.v n * Lib.IntTypes.v n <= Lib.IntTypes.max_size_t /\ Lib.IntTypes.v n <= Lib.IntTypes.maxint Lib.IntTypes.U16 /\ Lib.IntTypes.v n % 4 = 0 } -> seed: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul -> a_matrix: Hacl.Impl.Matrix.matrix_t n n -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 79, "end_line": 131, "start_col": 2, "start_line": 130 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul)
let ct1bytes_len (a: S.frodo_alg) =
false
null
false
params_logq a *! (params_nbar *! params_n a /. 8ul)
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.params_logq", "Lib.IntTypes.op_Slash_Dot", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.int_t" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ct1bytes_len : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
[]
Hacl.Impl.Frodo.Params.ct1bytes_len
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{ "end_col": 53, "end_line": 71, "start_col": 2, "start_line": 71 }
Prims.Tot
val cdf_table1344:x: glbuffer uint16 7ul {witnessed x (S.cdf_table S.Frodo1344) /\ recallable x}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cdf_table1344 :x:glbuffer uint16 7ul{witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} = createL_global S.cdf_list_1344
val cdf_table1344:x: glbuffer uint16 7ul {witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} let cdf_table1344:x: glbuffer uint16 7ul {witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} =
false
null
false
createL_global S.cdf_list_1344
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Spec.Frodo.Params.cdf_list_1344", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a inline_for_extraction noextract let frodo_shake_st (a:S.frodo_alg) = inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> outputByteLen:size_t -> output:lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) inline_for_extraction noextract let frodo_shake (a:S.frodo_alg) : frodo_shake_st a = match a with | S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl | S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl inline_for_extraction noextract let is_supported (a:S.frodo_gen_a) = match a with | S.SHAKE128 -> true | S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *) val frodo_gen_matrix: a:S.frodo_gen_a{is_supported a} -> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0} -> seed:lbuffer uint8 16ul -> a_matrix:matrix_t n n -> Stack unit (requires fun h -> live h seed /\ live h a_matrix /\ disjoint seed a_matrix) (ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\ as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) [@CInline] let frodo_gen_matrix a n seed a_matrix = match a with | S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix (* | S.AES128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_aes n seed a_matrix *) (** CDF tables *) let cdf_table640 :x:glbuffer uint16 13ul{witnessed x (S.cdf_table S.Frodo640) /\ recallable x} = createL_global S.cdf_list_640 let cdf_table976 :x:glbuffer uint16 11ul{witnessed x (S.cdf_table S.Frodo976) /\ recallable x} = createL_global S.cdf_list_976
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cdf_table1344:x: glbuffer uint16 7ul {witnessed x (S.cdf_table S.Frodo1344) /\ recallable x}
[]
Hacl.Impl.Frodo.Params.cdf_table1344
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: (c: Lib.Buffer.lbuffer_t Lib.Buffer.CONST (Lib.IntTypes.int_t Lib.IntTypes.U16 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 7 <: FStar.UInt32.t) {LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE}) { Lib.Buffer.witnessed x (Spec.Frodo.Params.cdf_table Spec.Frodo.Params.Frodo1344) /\ Lib.Buffer.recallable x }
{ "end_col": 32, "end_line": 144, "start_col": 2, "start_line": 144 }
Prims.Tot
val bytes_mu (a: S.frodo_alg) : x: size_t{v x == S.bytes_mu a}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
val bytes_mu (a: S.frodo_alg) : x: size_t{v x == S.bytes_mu a} let bytes_mu (a: S.frodo_alg) : x: size_t{v x == S.bytes_mu a} =
false
null
false
params_extracted_bits a *! params_nbar *! params_nbar /. 8ul
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.op_Slash_Dot", "Lib.IntTypes.U32", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.params_extracted_bits", "Hacl.Impl.Frodo.Params.params_nbar", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Lib.IntTypes.v", "Spec.Frodo.Params.bytes_mu" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bytes_mu (a: S.frodo_alg) : x: size_t{v x == S.bytes_mu a}
[]
Hacl.Impl.Frodo.Params.bytes_mu
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> x: Lib.IntTypes.size_t{Lib.IntTypes.v x == Spec.Frodo.Params.bytes_mu a}
{ "end_col": 62, "end_line": 59, "start_col": 2, "start_line": 59 }
Prims.Tot
val cdf_table640:x: glbuffer uint16 13ul {witnessed x (S.cdf_table S.Frodo640) /\ recallable x}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cdf_table640 :x:glbuffer uint16 13ul{witnessed x (S.cdf_table S.Frodo640) /\ recallable x} = createL_global S.cdf_list_640
val cdf_table640:x: glbuffer uint16 13ul {witnessed x (S.cdf_table S.Frodo640) /\ recallable x} let cdf_table640:x: glbuffer uint16 13ul {witnessed x (S.cdf_table S.Frodo640) /\ recallable x} =
false
null
false
createL_global S.cdf_list_640
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Spec.Frodo.Params.cdf_list_640", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a inline_for_extraction noextract let frodo_shake_st (a:S.frodo_alg) = inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> outputByteLen:size_t -> output:lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) inline_for_extraction noextract let frodo_shake (a:S.frodo_alg) : frodo_shake_st a = match a with | S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl | S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl inline_for_extraction noextract let is_supported (a:S.frodo_gen_a) = match a with | S.SHAKE128 -> true | S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *) val frodo_gen_matrix: a:S.frodo_gen_a{is_supported a} -> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0} -> seed:lbuffer uint8 16ul -> a_matrix:matrix_t n n -> Stack unit (requires fun h -> live h seed /\ live h a_matrix /\ disjoint seed a_matrix) (ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\ as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) [@CInline] let frodo_gen_matrix a n seed a_matrix = match a with | S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix (* | S.AES128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_aes n seed a_matrix *) (** CDF tables *)
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cdf_table640:x: glbuffer uint16 13ul {witnessed x (S.cdf_table S.Frodo640) /\ recallable x}
[]
Hacl.Impl.Frodo.Params.cdf_table640
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: (c: Lib.Buffer.lbuffer_t Lib.Buffer.CONST (Lib.IntTypes.int_t Lib.IntTypes.U16 Lib.IntTypes.SEC) (FStar.UInt32.uint_to_t 13 <: FStar.UInt32.t) {LowStar.ConstBuffer.qual_of c == LowStar.ConstBuffer.IMMUTABLE}) { Lib.Buffer.witnessed x (Spec.Frodo.Params.cdf_table Spec.Frodo.Params.Frodo640) /\ Lib.Buffer.recallable x }
{ "end_col": 31, "end_line": 138, "start_col": 2, "start_line": 138 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a
let crypto_secretkeybytes (a: S.frodo_alg) =
false
null
false
crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.crypto_bytes", "Hacl.Impl.Frodo.Params.crypto_publickeybytes", "Hacl.Impl.Frodo.Params.secretmatrixbytes_len", "Hacl.Impl.Frodo.Params.bytes_pkhash", "Lib.IntTypes.int_t" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract
false
true
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_secretkeybytes : a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
[]
Hacl.Impl.Frodo.Params.crypto_secretkeybytes
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB
{ "end_col": 88, "end_line": 83, "start_col": 2, "start_line": 83 }
Prims.Tot
val cdf_table (a: S.frodo_alg) : x: glbuffer uint16 (cdf_table_len a) {witnessed x (S.cdf_table a) /\ recallable x}
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cdf_table (a:S.frodo_alg) :x:glbuffer uint16 (cdf_table_len a) {witnessed x (S.cdf_table a) /\ recallable x} = allow_inversion S.frodo_alg; match a with | S.Frodo64 | S.Frodo640 -> cdf_table640 | S.Frodo976 -> cdf_table976 | S.Frodo1344 -> cdf_table1344
val cdf_table (a: S.frodo_alg) : x: glbuffer uint16 (cdf_table_len a) {witnessed x (S.cdf_table a) /\ recallable x} let cdf_table (a: S.frodo_alg) : x: glbuffer uint16 (cdf_table_len a) {witnessed x (S.cdf_table a) /\ recallable x} =
false
null
false
allow_inversion S.frodo_alg; match a with | S.Frodo64 | S.Frodo640 -> cdf_table640 | S.Frodo976 -> cdf_table976 | S.Frodo1344 -> cdf_table1344
{ "checked_file": "Hacl.Impl.Frodo.Params.fst.checked", "dependencies": [ "Spec.Frodo.Params.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.SHA3.fst.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Gen.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Params.fst" }
[ "total" ]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.Impl.Frodo.Params.cdf_table640", "Hacl.Impl.Frodo.Params.cdf_table976", "Hacl.Impl.Frodo.Params.cdf_table1344", "Lib.Buffer.glbuffer", "Lib.IntTypes.uint16", "Hacl.Impl.Frodo.Params.cdf_table_len", "Prims.l_and", "Lib.Buffer.witnessed", "Spec.Frodo.Params.cdf_table", "Lib.Buffer.recallable", "Lib.Buffer.CONST", "Prims.unit", "FStar.Pervasives.allow_inversion" ]
[]
module Hacl.Impl.Frodo.Params open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix module S = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let params_n (a:S.frodo_alg) : x:size_t{v x == S.params_n a} = match a with | S.Frodo64 -> 64ul | S.Frodo640 -> 640ul | S.Frodo976 -> 976ul | S.Frodo1344 -> 1344ul inline_for_extraction noextract let params_logq (a:S.frodo_alg) : x:size_t{v x == S.params_logq a} = match a with | S.Frodo64 | S.Frodo640 -> 15ul | S.Frodo976 | S.Frodo1344 -> 16ul inline_for_extraction noextract let params_extracted_bits (a:S.frodo_alg) : x:size_t{v x == S.params_extracted_bits a} = match a with | S.Frodo64 | S.Frodo640 -> 2ul | S.Frodo976 -> 3ul | S.Frodo1344 -> 4ul inline_for_extraction noextract let crypto_bytes (a:S.frodo_alg) : x:size_t{v x == S.crypto_bytes a} = match a with | S.Frodo64 | S.Frodo640 -> 16ul | S.Frodo976 -> 24ul | S.Frodo1344 -> 32ul inline_for_extraction noextract let params_nbar = 8ul inline_for_extraction noextract let bytes_seed_a = 16ul inline_for_extraction noextract let bytes_pkhash (a:S.frodo_alg) = crypto_bytes a inline_for_extraction noextract let bytes_mu (a:S.frodo_alg) : x:size_t{v x == S.bytes_mu a} = params_extracted_bits a *! params_nbar *! params_nbar /. 8ul inline_for_extraction noextract let publicmatrixbytes_len (a:S.frodo_alg) = params_logq a *! (params_n a *! params_nbar /. 8ul) inline_for_extraction noextract let secretmatrixbytes_len (a:S.frodo_alg) = 2ul *! params_n a *! params_nbar inline_for_extraction noextract let ct1bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_n a /. 8ul) inline_for_extraction noextract let ct2bytes_len (a:S.frodo_alg) = params_logq a *! (params_nbar *! params_nbar /. 8ul) inline_for_extraction noextract let crypto_publickeybytes (a:S.frodo_alg) = bytes_seed_a +! publicmatrixbytes_len a inline_for_extraction noextract let crypto_secretkeybytes (a:S.frodo_alg) = crypto_bytes a +! crypto_publickeybytes a +! secretmatrixbytes_len a +! bytes_pkhash a inline_for_extraction noextract let crypto_ciphertextbytes (a:S.frodo_alg) = ct1bytes_len a +! ct2bytes_len a inline_for_extraction noextract let frodo_shake_st (a:S.frodo_alg) = inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> outputByteLen:size_t -> output:lbuffer uint8 outputByteLen -> Stack unit (requires fun h -> live h input /\ live h output /\ disjoint input output) (ensures fun h0 _ h1 -> modifies (loc output) h0 h1 /\ as_seq h1 output == S.frodo_shake a (v inputByteLen) (as_seq h0 input) (v outputByteLen)) inline_for_extraction noextract let frodo_shake (a:S.frodo_alg) : frodo_shake_st a = match a with | S.Frodo64 | S.Frodo640 -> Hacl.SHA3.shake128_hacl | S.Frodo976 | S.Frodo1344 -> Hacl.SHA3.shake256_hacl inline_for_extraction noextract let is_supported (a:S.frodo_gen_a) = match a with | S.SHAKE128 -> true | S.AES128 -> false (* unfortunately, we don't have a verified impl of aes128 in Low* *) val frodo_gen_matrix: a:S.frodo_gen_a{is_supported a} -> n:size_t{0 < v n /\ v n * v n <= max_size_t /\ v n <= maxint U16 /\ v n % 4 = 0} -> seed:lbuffer uint8 16ul -> a_matrix:matrix_t n n -> Stack unit (requires fun h -> live h seed /\ live h a_matrix /\ disjoint seed a_matrix) (ensures fun h0 _ h1 -> modifies1 a_matrix h0 h1 /\ as_matrix h1 a_matrix == S.frodo_gen_matrix a (v n) (as_seq h0 seed)) [@CInline] let frodo_gen_matrix a n seed a_matrix = match a with | S.SHAKE128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_shake_4x n seed a_matrix (* | S.AES128 -> Hacl.Impl.Frodo.Gen.frodo_gen_matrix_aes n seed a_matrix *) (** CDF tables *) let cdf_table640 :x:glbuffer uint16 13ul{witnessed x (S.cdf_table S.Frodo640) /\ recallable x} = createL_global S.cdf_list_640 let cdf_table976 :x:glbuffer uint16 11ul{witnessed x (S.cdf_table S.Frodo976) /\ recallable x} = createL_global S.cdf_list_976 let cdf_table1344 :x:glbuffer uint16 7ul{witnessed x (S.cdf_table S.Frodo1344) /\ recallable x} = createL_global S.cdf_list_1344 inline_for_extraction noextract let cdf_table_len (a:S.frodo_alg) : x:size_t{v x = S.cdf_table_len a} = allow_inversion S.frodo_alg; match a with | S.Frodo64 | S.Frodo640 -> 13ul | S.Frodo976 -> 11ul | S.Frodo1344 -> 7ul inline_for_extraction noextract let cdf_table (a:S.frodo_alg) :x:glbuffer uint16 (cdf_table_len a) {witnessed x (S.cdf_table a) /\ recallable x}
false
false
Hacl.Impl.Frodo.Params.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cdf_table (a: S.frodo_alg) : x: glbuffer uint16 (cdf_table_len a) {witnessed x (S.cdf_table a) /\ recallable x}
[]
Hacl.Impl.Frodo.Params.cdf_table
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Params.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> x: Lib.Buffer.glbuffer Lib.IntTypes.uint16 (Hacl.Impl.Frodo.Params.cdf_table_len a) {Lib.Buffer.witnessed x (Spec.Frodo.Params.cdf_table a) /\ Lib.Buffer.recallable x}
{ "end_col": 32, "end_line": 164, "start_col": 2, "start_line": 160 }
Prims.Tot
val fsqrt: f:S.felem -> S.felem
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r
val fsqrt: f:S.felem -> S.felem let fsqrt f =
false
null
false
let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "total" ]
[ "Spec.K256.PointOps.felem", "Hacl.Spec.K256.Finv.fsquare_times", "Spec.K256.PointOps.fmul", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.K256.Finv.fexp_223_23" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r
false
true
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fsqrt: f:S.felem -> S.felem
[]
Hacl.Spec.K256.Finv.fsqrt
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem
{ "end_col": 3, "end_line": 84, "start_col": 13, "start_line": 80 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime
let nat_mod_comm_monoid =
false
null
false
M.mk_nat_mod_comm_monoid S.prime
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "total" ]
[ "Lib.NatMod.mk_nat_mod_comm_monoid", "Spec.K256.PointOps.prime" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
true
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat_mod_comm_monoid : Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod Spec.K256.PointOps.prime)
[]
Hacl.Spec.K256.Finv.nat_mod_comm_monoid
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod Spec.K256.PointOps.prime)
{ "end_col": 58, "end_line": 12, "start_col": 26, "start_line": 12 }
Prims.Tot
val finv: f:S.felem -> S.felem
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r
val finv: f:S.felem -> S.felem let finv f =
false
null
false
let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "total" ]
[ "Spec.K256.PointOps.felem", "Spec.K256.PointOps.fmul", "Hacl.Spec.K256.Finv.fsquare_times", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.K256.Finv.fexp_223_23" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *)
false
true
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finv: f:S.felem -> S.felem
[]
Hacl.Spec.K256.Finv.finv
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem
{ "end_col": 3, "end_line": 76, "start_col": 12, "start_line": 71 }
Prims.Tot
val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2
val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f =
false
null
false
let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "total" ]
[ "Spec.K256.PointOps.felem", "FStar.Pervasives.Native.Mktuple2", "Spec.K256.PointOps.fmul", "Hacl.Spec.K256.Finv.fsquare_times", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b)
false
true
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem
[]
Hacl.Spec.K256.Finv.fexp_223_23
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> Spec.K256.PointOps.felem * Spec.K256.PointOps.felem
{ "end_col": 7, "end_line": 62, "start_col": 19, "start_line": 49 }
Prims.Tot
val fsquare_times (a: S.felem) (b: nat) : S.felem
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b
val fsquare_times (a: S.felem) (b: nat) : S.felem let fsquare_times (a: S.felem) (b: nat) : S.felem =
false
null
false
SE.exp_pow2 mk_nat_mod_concrete_ops a b
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "total" ]
[ "Spec.K256.PointOps.felem", "Prims.nat", "Spec.Exponentiation.exp_pow2", "Hacl.Spec.K256.Finv.mk_nat_mod_concrete_ops" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; }
false
true
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fsquare_times (a: S.felem) (b: nat) : S.felem
[]
Hacl.Spec.K256.Finv.fsquare_times
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.K256.PointOps.felem -> b: Prims.nat -> Spec.K256.PointOps.felem
{ "end_col": 41, "end_line": 37, "start_col": 2, "start_line": 37 }
Prims.Tot
val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sqr_mod x = S.fmul x x
val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x =
false
null
false
S.fmul x x
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "total" ]
[ "Spec.K256.PointOps.felem", "Spec.K256.PointOps.fmul" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y
false
true
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid
[]
Hacl.Spec.K256.Finv.sqr_mod
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.sqr_st Spec.K256.PointOps.felem Hacl.Spec.K256.Finv.mk_to_nat_mod_comm_monoid
{ "end_col": 26, "end_line": 27, "start_col": 16, "start_line": 27 }
Prims.Tot
val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_mod x y = S.fmul x y
val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y =
false
null
false
S.fmul x y
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "total" ]
[ "Spec.K256.PointOps.felem", "Spec.K256.PointOps.fmul" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one
false
true
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid
[]
Hacl.Spec.K256.Finv.mul_mod
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.mul_st Spec.K256.PointOps.felem Hacl.Spec.K256.Finv.mk_to_nat_mod_comm_monoid
{ "end_col": 28, "end_line": 24, "start_col": 18, "start_line": 24 }
Prims.Tot
val is_fsqrt: f:S.felem -> f2:S.felem -> bool
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let is_fsqrt f f2 = S.fmul f f = f2
val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 =
false
null
false
S.fmul f f = f2
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "total" ]
[ "Spec.K256.PointOps.felem", "Prims.op_Equality", "Spec.K256.PointOps.fmul", "Prims.bool" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r
false
true
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_fsqrt: f:S.felem -> f2:S.felem -> bool
[]
Hacl.Spec.K256.Finv.is_fsqrt
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> f2: Spec.K256.PointOps.felem -> Prims.bool
{ "end_col": 35, "end_line": 88, "start_col": 20, "start_line": 88 }
FStar.Pervasives.Lemma
val fsqrt_is_fsqrt_lemma: f:S.felem -> Lemma (fsqrt f == S.fsqrt f)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fsqrt_is_fsqrt_lemma f = fsqrt_lemma f; assert (fsqrt f == M.pow f ((S.prime + 1) / 4) % S.prime); M.lemma_pow_mod #S.prime f ((S.prime + 1) / 4)
val fsqrt_is_fsqrt_lemma: f:S.felem -> Lemma (fsqrt f == S.fsqrt f) let fsqrt_is_fsqrt_lemma f =
false
null
true
fsqrt_lemma f; assert (fsqrt f == M.pow f ((S.prime + 1) / 4) % S.prime); M.lemma_pow_mod #S.prime f ((S.prime + 1) / 4)
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "Lib.NatMod.lemma_pow_mod", "Spec.K256.PointOps.prime", "Prims.op_Division", "Prims.op_Addition", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Hacl.Spec.K256.Finv.fsqrt", "Prims.op_Modulus", "Lib.NatMod.pow", "Hacl.Spec.K256.Finv.fsqrt_lemma" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 = S.fmul f f = f2 val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime) val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime) let lemma_pow_mod_mul f a b = calc (==) { S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.prime) S.prime; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.prime } M.pow f a * M.pow f b % S.prime; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.prime; } val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime) let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.prime) b % S.prime; (==) { M.lemma_pow_mod_base (M.pow f a) b S.prime } M.pow (M.pow f a) b % S.prime; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.prime; } val lemma_pow_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> c:nat -> Lemma (S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime) == M.pow f (a * b + c) % S.prime) let lemma_pow_pow_mod_mul f a b c = calc (==) { S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_pow_mod f a b } S.fmul (M.pow f (a * b) % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.prime; } val fexp_223_23_lemma: f:S.felem -> Lemma (let (r, x2) = fexp_223_23 f in x2 == M.pow f 0x3 % S.prime /\ r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime) let fexp_223_23_lemma f = let x2 = S.fmul (fsquare_times f 1) f in fsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x2 == M.pow f 0x3 % S.prime); let x3 = S.fmul (fsquare_times x2 1) f in fsquare_times_lemma x2 1; lemma_pow_mod_1 f; lemma_pow_pow_mod_mul f 0x3 0x2 0x1; assert (x3 == M.pow f 0x7 % S.prime); let x6 = S.fmul (fsquare_times x3 3) x3 in fsquare_times_lemma x3 3; assert_norm (pow2 3 = 8); lemma_pow_pow_mod_mul f 0x7 0x8 0x7; assert (x6 == M.pow f 0x3f % S.prime); let x9 = S.fmul (fsquare_times x6 3) x3 in fsquare_times_lemma x6 3; lemma_pow_pow_mod_mul f 0x3f 0x8 0x7; assert (x9 == M.pow f 0x1ff % S.prime); let x11 = S.fmul (fsquare_times x9 2) x2 in fsquare_times_lemma x9 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0x1ff 0x4 0x3; assert (x11 == M.pow f 0x7ff % S.prime); let x22 = S.fmul (fsquare_times x11 11) x11 in fsquare_times_lemma x11 11; assert_norm (pow2 11 = 0x800); lemma_pow_pow_mod_mul f 0x7ff 0x800 0x7ff; assert (x22 == M.pow f 0x3fffff % S.prime); let x44 = S.fmul (fsquare_times x22 22) x22 in fsquare_times_lemma x22 22; assert_norm (pow2 22 = 0x400000); lemma_pow_pow_mod_mul f 0x3fffff 0x400000 0x3fffff; assert (x44 == M.pow f 0xfffffffffff % S.prime); let x88 = S.fmul (fsquare_times x44 44) x44 in fsquare_times_lemma x44 44; assert_norm (pow2 44 = 0x100000000000); lemma_pow_pow_mod_mul f 0xfffffffffff 0x100000000000 0xfffffffffff; assert (x88 == M.pow f 0xffffffffffffffffffffff % S.prime); let x176 = S.fmul (fsquare_times x88 88) x88 in fsquare_times_lemma x88 88; assert_norm (pow2 88 = 0x10000000000000000000000); lemma_pow_pow_mod_mul f 0xffffffffffffffffffffff 0x10000000000000000000000 0xffffffffffffffffffffff; assert (x176 == M.pow f 0xffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x220 = S.fmul (fsquare_times x176 44) x44 in fsquare_times_lemma x176 44; lemma_pow_pow_mod_mul f 0xffffffffffffffffffffffffffffffffffffffffffff 0x100000000000 0xfffffffffff; assert (x220 == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x223 = S.fmul (fsquare_times x220 3) x3 in fsquare_times_lemma x220 3; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x8 0x7; assert (x223 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let r0 = S.fmul (fsquare_times x223 23) x22 in fsquare_times_lemma x223 23; assert_norm (pow2 23 = 0x800000); lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x800000 0x3fffff; assert (r0 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime) // S.prime - 2 = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d val finv_lemma: f:S.felem -> Lemma (finv f == M.pow f (S.prime - 2) % S.prime) let finv_lemma f = lemma_pow_mod_1 f; let r0, x2 = fexp_223_23 f in fexp_223_23_lemma f; let r1 = S.fmul (fsquare_times r0 5) f in fsquare_times_lemma r0 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff 0x20 0x1; assert (r1 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 % S.prime); let r2 = S.fmul (fsquare_times r1 3) x2 in fsquare_times_lemma r1 3; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 0x8 0x3; assert (r2 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b % S.prime); let r = S.fmul (fsquare_times r2 2) f in fsquare_times_lemma r2 2; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b 0x4 0x1; assert (r == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d % S.prime) val finv_is_finv_lemma: f:S.felem -> Lemma (finv f == S.finv f) let finv_is_finv_lemma f = finv_lemma f; assert (finv f == M.pow f (S.prime - 2) % S.prime); M.lemma_pow_mod #S.prime f (S.prime - 2) val fsqrt_lemma: f:S.felem -> Lemma (fsqrt f == M.pow f ((S.prime + 1) / 4) % S.prime) let fsqrt_lemma f = lemma_pow_mod_1 f; let r0, x2 = fexp_223_23 f in fexp_223_23_lemma f; let r1 = S.fmul (fsquare_times r0 6) x2 in fsquare_times_lemma r0 6; assert_norm (pow2 6 = 0x40); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff 0x40 0x3; assert (r1 == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc3 % S.prime); let r = fsquare_times r1 2 in fsquare_times_lemma r1 2; assert_norm (pow2 2 = 4); lemma_pow_pow_mod f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc3 0x4; assert (r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c % S.prime); assert_norm (0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c == (S.prime + 1) / 4) val fsqrt_is_fsqrt_lemma: f:S.felem -> Lemma (fsqrt f == S.fsqrt f)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fsqrt_is_fsqrt_lemma: f:S.felem -> Lemma (fsqrt f == S.fsqrt f)
[]
Hacl.Spec.K256.Finv.fsqrt_is_fsqrt_lemma
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.Finv.fsqrt f == Spec.K256.PointOps.fsqrt f)
{ "end_col": 48, "end_line": 271, "start_col": 2, "start_line": 269 }
FStar.Pervasives.Lemma
val finv_is_finv_lemma: f:S.felem -> Lemma (finv f == S.finv f)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finv_is_finv_lemma f = finv_lemma f; assert (finv f == M.pow f (S.prime - 2) % S.prime); M.lemma_pow_mod #S.prime f (S.prime - 2)
val finv_is_finv_lemma: f:S.felem -> Lemma (finv f == S.finv f) let finv_is_finv_lemma f =
false
null
true
finv_lemma f; assert (finv f == M.pow f (S.prime - 2) % S.prime); M.lemma_pow_mod #S.prime f (S.prime - 2)
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "Lib.NatMod.lemma_pow_mod", "Spec.K256.PointOps.prime", "Prims.op_Subtraction", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Hacl.Spec.K256.Finv.finv", "Prims.op_Modulus", "Lib.NatMod.pow", "Hacl.Spec.K256.Finv.finv_lemma" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 = S.fmul f f = f2 val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime) val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime) let lemma_pow_mod_mul f a b = calc (==) { S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.prime) S.prime; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.prime } M.pow f a * M.pow f b % S.prime; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.prime; } val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime) let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.prime) b % S.prime; (==) { M.lemma_pow_mod_base (M.pow f a) b S.prime } M.pow (M.pow f a) b % S.prime; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.prime; } val lemma_pow_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> c:nat -> Lemma (S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime) == M.pow f (a * b + c) % S.prime) let lemma_pow_pow_mod_mul f a b c = calc (==) { S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_pow_mod f a b } S.fmul (M.pow f (a * b) % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.prime; } val fexp_223_23_lemma: f:S.felem -> Lemma (let (r, x2) = fexp_223_23 f in x2 == M.pow f 0x3 % S.prime /\ r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime) let fexp_223_23_lemma f = let x2 = S.fmul (fsquare_times f 1) f in fsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x2 == M.pow f 0x3 % S.prime); let x3 = S.fmul (fsquare_times x2 1) f in fsquare_times_lemma x2 1; lemma_pow_mod_1 f; lemma_pow_pow_mod_mul f 0x3 0x2 0x1; assert (x3 == M.pow f 0x7 % S.prime); let x6 = S.fmul (fsquare_times x3 3) x3 in fsquare_times_lemma x3 3; assert_norm (pow2 3 = 8); lemma_pow_pow_mod_mul f 0x7 0x8 0x7; assert (x6 == M.pow f 0x3f % S.prime); let x9 = S.fmul (fsquare_times x6 3) x3 in fsquare_times_lemma x6 3; lemma_pow_pow_mod_mul f 0x3f 0x8 0x7; assert (x9 == M.pow f 0x1ff % S.prime); let x11 = S.fmul (fsquare_times x9 2) x2 in fsquare_times_lemma x9 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0x1ff 0x4 0x3; assert (x11 == M.pow f 0x7ff % S.prime); let x22 = S.fmul (fsquare_times x11 11) x11 in fsquare_times_lemma x11 11; assert_norm (pow2 11 = 0x800); lemma_pow_pow_mod_mul f 0x7ff 0x800 0x7ff; assert (x22 == M.pow f 0x3fffff % S.prime); let x44 = S.fmul (fsquare_times x22 22) x22 in fsquare_times_lemma x22 22; assert_norm (pow2 22 = 0x400000); lemma_pow_pow_mod_mul f 0x3fffff 0x400000 0x3fffff; assert (x44 == M.pow f 0xfffffffffff % S.prime); let x88 = S.fmul (fsquare_times x44 44) x44 in fsquare_times_lemma x44 44; assert_norm (pow2 44 = 0x100000000000); lemma_pow_pow_mod_mul f 0xfffffffffff 0x100000000000 0xfffffffffff; assert (x88 == M.pow f 0xffffffffffffffffffffff % S.prime); let x176 = S.fmul (fsquare_times x88 88) x88 in fsquare_times_lemma x88 88; assert_norm (pow2 88 = 0x10000000000000000000000); lemma_pow_pow_mod_mul f 0xffffffffffffffffffffff 0x10000000000000000000000 0xffffffffffffffffffffff; assert (x176 == M.pow f 0xffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x220 = S.fmul (fsquare_times x176 44) x44 in fsquare_times_lemma x176 44; lemma_pow_pow_mod_mul f 0xffffffffffffffffffffffffffffffffffffffffffff 0x100000000000 0xfffffffffff; assert (x220 == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x223 = S.fmul (fsquare_times x220 3) x3 in fsquare_times_lemma x220 3; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x8 0x7; assert (x223 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let r0 = S.fmul (fsquare_times x223 23) x22 in fsquare_times_lemma x223 23; assert_norm (pow2 23 = 0x800000); lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x800000 0x3fffff; assert (r0 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime) // S.prime - 2 = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d val finv_lemma: f:S.felem -> Lemma (finv f == M.pow f (S.prime - 2) % S.prime) let finv_lemma f = lemma_pow_mod_1 f; let r0, x2 = fexp_223_23 f in fexp_223_23_lemma f; let r1 = S.fmul (fsquare_times r0 5) f in fsquare_times_lemma r0 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff 0x20 0x1; assert (r1 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 % S.prime); let r2 = S.fmul (fsquare_times r1 3) x2 in fsquare_times_lemma r1 3; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 0x8 0x3; assert (r2 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b % S.prime); let r = S.fmul (fsquare_times r2 2) f in fsquare_times_lemma r2 2; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b 0x4 0x1; assert (r == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d % S.prime) val finv_is_finv_lemma: f:S.felem -> Lemma (finv f == S.finv f)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finv_is_finv_lemma: f:S.felem -> Lemma (finv f == S.finv f)
[]
Hacl.Spec.K256.Finv.finv_is_finv_lemma
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.Finv.finv f == Spec.K256.PointOps.finv f)
{ "end_col": 42, "end_line": 243, "start_col": 2, "start_line": 241 }
Prims.Tot
val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let one_mod _ = S.one
val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ =
false
null
false
S.one
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "total" ]
[ "Prims.unit", "Spec.K256.PointOps.one", "Spec.K256.PointOps.felem" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); }
false
true
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid
[]
Hacl.Spec.K256.Finv.one_mod
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.one_st Spec.K256.PointOps.felem Hacl.Spec.K256.Finv.mk_to_nat_mod_comm_monoid
{ "end_col": 21, "end_line": 21, "start_col": 16, "start_line": 21 }
FStar.Pervasives.Lemma
val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime)
val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime) let lemma_pow_mod_1 f =
false
null
true
M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime)
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.prime", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.pow2", "FStar.Math.Lemmas.small_mod", "Lib.NatMod.lemma_pow1" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 = S.fmul f f = f2 val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime)
[]
Hacl.Spec.K256.Finv.lemma_pow_mod_1
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> FStar.Pervasives.Lemma (ensures f == Lib.NatMod.pow f 1 % Spec.K256.PointOps.prime)
{ "end_col": 35, "end_line": 96, "start_col": 2, "start_line": 93 }
FStar.Pervasives.Lemma
val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b)
val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b =
false
null
true
SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b)
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "Prims.nat", "Lib.NatMod.lemma_pow_nat_mod_is_pow", "Spec.K256.PointOps.prime", "Prims.pow2", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.l_or", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.K256.Finv.fsquare_times", "Lib.Exponentiation.Definition.pow", "Lib.NatMod.nat_mod", "Hacl.Spec.K256.Finv.nat_mod_comm_monoid", "Lib.Exponentiation.exp_pow2_lemma", "Spec.Exponentiation.exp_pow2_lemma", "Hacl.Spec.K256.Finv.mk_nat_mod_concrete_ops" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime)
[]
Hacl.Spec.K256.Finv.fsquare_times_lemma
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.K256.PointOps.felem -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.Finv.fsquare_times a b == Lib.NatMod.pow a (Prims.pow2 b) % Spec.K256.PointOps.prime)
{ "end_col": 48, "end_line": 45, "start_col": 2, "start_line": 42 }
FStar.Pervasives.Lemma
val finv_lemma: f:S.felem -> Lemma (finv f == M.pow f (S.prime - 2) % S.prime)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finv_lemma f = lemma_pow_mod_1 f; let r0, x2 = fexp_223_23 f in fexp_223_23_lemma f; let r1 = S.fmul (fsquare_times r0 5) f in fsquare_times_lemma r0 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff 0x20 0x1; assert (r1 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 % S.prime); let r2 = S.fmul (fsquare_times r1 3) x2 in fsquare_times_lemma r1 3; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 0x8 0x3; assert (r2 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b % S.prime); let r = S.fmul (fsquare_times r2 2) f in fsquare_times_lemma r2 2; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b 0x4 0x1; assert (r == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d % S.prime)
val finv_lemma: f:S.felem -> Lemma (finv f == M.pow f (S.prime - 2) % S.prime) let finv_lemma f =
false
null
true
lemma_pow_mod_1 f; let r0, x2 = fexp_223_23 f in fexp_223_23_lemma f; let r1 = S.fmul (fsquare_times r0 5) f in fsquare_times_lemma r0 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff 0x20 0x1; assert (r1 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 % S.prime); let r2 = S.fmul (fsquare_times r1 3) x2 in fsquare_times_lemma r1 3; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 0x8 0x3; assert (r2 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b % S.prime); let r = S.fmul (fsquare_times r2 2) f in fsquare_times_lemma r2 2; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b 0x4 0x1; assert (r == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d % S.prime)
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.prime", "Prims.unit", "Hacl.Spec.K256.Finv.lemma_pow_pow_mod_mul", "Hacl.Spec.K256.Finv.fsquare_times_lemma", "Spec.K256.PointOps.fmul", "Hacl.Spec.K256.Finv.fsquare_times", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.pow2", "Hacl.Spec.K256.Finv.fexp_223_23_lemma", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.K256.Finv.fexp_223_23", "Hacl.Spec.K256.Finv.lemma_pow_mod_1" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 = S.fmul f f = f2 val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime) val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime) let lemma_pow_mod_mul f a b = calc (==) { S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.prime) S.prime; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.prime } M.pow f a * M.pow f b % S.prime; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.prime; } val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime) let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.prime) b % S.prime; (==) { M.lemma_pow_mod_base (M.pow f a) b S.prime } M.pow (M.pow f a) b % S.prime; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.prime; } val lemma_pow_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> c:nat -> Lemma (S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime) == M.pow f (a * b + c) % S.prime) let lemma_pow_pow_mod_mul f a b c = calc (==) { S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_pow_mod f a b } S.fmul (M.pow f (a * b) % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.prime; } val fexp_223_23_lemma: f:S.felem -> Lemma (let (r, x2) = fexp_223_23 f in x2 == M.pow f 0x3 % S.prime /\ r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime) let fexp_223_23_lemma f = let x2 = S.fmul (fsquare_times f 1) f in fsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x2 == M.pow f 0x3 % S.prime); let x3 = S.fmul (fsquare_times x2 1) f in fsquare_times_lemma x2 1; lemma_pow_mod_1 f; lemma_pow_pow_mod_mul f 0x3 0x2 0x1; assert (x3 == M.pow f 0x7 % S.prime); let x6 = S.fmul (fsquare_times x3 3) x3 in fsquare_times_lemma x3 3; assert_norm (pow2 3 = 8); lemma_pow_pow_mod_mul f 0x7 0x8 0x7; assert (x6 == M.pow f 0x3f % S.prime); let x9 = S.fmul (fsquare_times x6 3) x3 in fsquare_times_lemma x6 3; lemma_pow_pow_mod_mul f 0x3f 0x8 0x7; assert (x9 == M.pow f 0x1ff % S.prime); let x11 = S.fmul (fsquare_times x9 2) x2 in fsquare_times_lemma x9 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0x1ff 0x4 0x3; assert (x11 == M.pow f 0x7ff % S.prime); let x22 = S.fmul (fsquare_times x11 11) x11 in fsquare_times_lemma x11 11; assert_norm (pow2 11 = 0x800); lemma_pow_pow_mod_mul f 0x7ff 0x800 0x7ff; assert (x22 == M.pow f 0x3fffff % S.prime); let x44 = S.fmul (fsquare_times x22 22) x22 in fsquare_times_lemma x22 22; assert_norm (pow2 22 = 0x400000); lemma_pow_pow_mod_mul f 0x3fffff 0x400000 0x3fffff; assert (x44 == M.pow f 0xfffffffffff % S.prime); let x88 = S.fmul (fsquare_times x44 44) x44 in fsquare_times_lemma x44 44; assert_norm (pow2 44 = 0x100000000000); lemma_pow_pow_mod_mul f 0xfffffffffff 0x100000000000 0xfffffffffff; assert (x88 == M.pow f 0xffffffffffffffffffffff % S.prime); let x176 = S.fmul (fsquare_times x88 88) x88 in fsquare_times_lemma x88 88; assert_norm (pow2 88 = 0x10000000000000000000000); lemma_pow_pow_mod_mul f 0xffffffffffffffffffffff 0x10000000000000000000000 0xffffffffffffffffffffff; assert (x176 == M.pow f 0xffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x220 = S.fmul (fsquare_times x176 44) x44 in fsquare_times_lemma x176 44; lemma_pow_pow_mod_mul f 0xffffffffffffffffffffffffffffffffffffffffffff 0x100000000000 0xfffffffffff; assert (x220 == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x223 = S.fmul (fsquare_times x220 3) x3 in fsquare_times_lemma x220 3; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x8 0x7; assert (x223 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let r0 = S.fmul (fsquare_times x223 23) x22 in fsquare_times_lemma x223 23; assert_norm (pow2 23 = 0x800000); lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x800000 0x3fffff; assert (r0 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime) // S.prime - 2 = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d val finv_lemma: f:S.felem -> Lemma (finv f == M.pow f (S.prime - 2) % S.prime)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finv_lemma: f:S.felem -> Lemma (finv f == M.pow f (S.prime - 2) % S.prime)
[]
Hacl.Spec.K256.Finv.finv_lemma
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.Finv.finv f == Lib.NatMod.pow f (Spec.K256.PointOps.prime - 2) % Spec.K256.PointOps.prime)
{ "end_col": 100, "end_line": 236, "start_col": 2, "start_line": 217 }
FStar.Pervasives.Lemma
val fsqrt_lemma: f:S.felem -> Lemma (fsqrt f == M.pow f ((S.prime + 1) / 4) % S.prime)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fsqrt_lemma f = lemma_pow_mod_1 f; let r0, x2 = fexp_223_23 f in fexp_223_23_lemma f; let r1 = S.fmul (fsquare_times r0 6) x2 in fsquare_times_lemma r0 6; assert_norm (pow2 6 = 0x40); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff 0x40 0x3; assert (r1 == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc3 % S.prime); let r = fsquare_times r1 2 in fsquare_times_lemma r1 2; assert_norm (pow2 2 = 4); lemma_pow_pow_mod f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc3 0x4; assert (r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c % S.prime); assert_norm (0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c == (S.prime + 1) / 4)
val fsqrt_lemma: f:S.felem -> Lemma (fsqrt f == M.pow f ((S.prime + 1) / 4) % S.prime) let fsqrt_lemma f =
false
null
true
lemma_pow_mod_1 f; let r0, x2 = fexp_223_23 f in fexp_223_23_lemma f; let r1 = S.fmul (fsquare_times r0 6) x2 in fsquare_times_lemma r0 6; assert_norm (pow2 6 = 0x40); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff 0x40 0x3; assert (r1 == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc3 % S.prime); let r = fsquare_times r1 2 in fsquare_times_lemma r1 2; assert_norm (pow2 2 = 4); lemma_pow_pow_mod f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc3 0x4; assert (r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c % S.prime); assert_norm (0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c == (S.prime + 1) / 4 )
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.op_Division", "Prims.op_Addition", "Spec.K256.PointOps.prime", "Prims.unit", "Prims._assert", "Prims.op_Modulus", "Lib.NatMod.pow", "Hacl.Spec.K256.Finv.lemma_pow_pow_mod", "Prims.b2t", "Prims.op_Equality", "Prims.pow2", "Hacl.Spec.K256.Finv.fsquare_times_lemma", "Hacl.Spec.K256.Finv.fsquare_times", "Hacl.Spec.K256.Finv.lemma_pow_pow_mod_mul", "Spec.K256.PointOps.fmul", "Hacl.Spec.K256.Finv.fexp_223_23_lemma", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.K256.Finv.fexp_223_23", "Hacl.Spec.K256.Finv.lemma_pow_mod_1" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 = S.fmul f f = f2 val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime) val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime) let lemma_pow_mod_mul f a b = calc (==) { S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.prime) S.prime; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.prime } M.pow f a * M.pow f b % S.prime; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.prime; } val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime) let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.prime) b % S.prime; (==) { M.lemma_pow_mod_base (M.pow f a) b S.prime } M.pow (M.pow f a) b % S.prime; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.prime; } val lemma_pow_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> c:nat -> Lemma (S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime) == M.pow f (a * b + c) % S.prime) let lemma_pow_pow_mod_mul f a b c = calc (==) { S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_pow_mod f a b } S.fmul (M.pow f (a * b) % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.prime; } val fexp_223_23_lemma: f:S.felem -> Lemma (let (r, x2) = fexp_223_23 f in x2 == M.pow f 0x3 % S.prime /\ r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime) let fexp_223_23_lemma f = let x2 = S.fmul (fsquare_times f 1) f in fsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x2 == M.pow f 0x3 % S.prime); let x3 = S.fmul (fsquare_times x2 1) f in fsquare_times_lemma x2 1; lemma_pow_mod_1 f; lemma_pow_pow_mod_mul f 0x3 0x2 0x1; assert (x3 == M.pow f 0x7 % S.prime); let x6 = S.fmul (fsquare_times x3 3) x3 in fsquare_times_lemma x3 3; assert_norm (pow2 3 = 8); lemma_pow_pow_mod_mul f 0x7 0x8 0x7; assert (x6 == M.pow f 0x3f % S.prime); let x9 = S.fmul (fsquare_times x6 3) x3 in fsquare_times_lemma x6 3; lemma_pow_pow_mod_mul f 0x3f 0x8 0x7; assert (x9 == M.pow f 0x1ff % S.prime); let x11 = S.fmul (fsquare_times x9 2) x2 in fsquare_times_lemma x9 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0x1ff 0x4 0x3; assert (x11 == M.pow f 0x7ff % S.prime); let x22 = S.fmul (fsquare_times x11 11) x11 in fsquare_times_lemma x11 11; assert_norm (pow2 11 = 0x800); lemma_pow_pow_mod_mul f 0x7ff 0x800 0x7ff; assert (x22 == M.pow f 0x3fffff % S.prime); let x44 = S.fmul (fsquare_times x22 22) x22 in fsquare_times_lemma x22 22; assert_norm (pow2 22 = 0x400000); lemma_pow_pow_mod_mul f 0x3fffff 0x400000 0x3fffff; assert (x44 == M.pow f 0xfffffffffff % S.prime); let x88 = S.fmul (fsquare_times x44 44) x44 in fsquare_times_lemma x44 44; assert_norm (pow2 44 = 0x100000000000); lemma_pow_pow_mod_mul f 0xfffffffffff 0x100000000000 0xfffffffffff; assert (x88 == M.pow f 0xffffffffffffffffffffff % S.prime); let x176 = S.fmul (fsquare_times x88 88) x88 in fsquare_times_lemma x88 88; assert_norm (pow2 88 = 0x10000000000000000000000); lemma_pow_pow_mod_mul f 0xffffffffffffffffffffff 0x10000000000000000000000 0xffffffffffffffffffffff; assert (x176 == M.pow f 0xffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x220 = S.fmul (fsquare_times x176 44) x44 in fsquare_times_lemma x176 44; lemma_pow_pow_mod_mul f 0xffffffffffffffffffffffffffffffffffffffffffff 0x100000000000 0xfffffffffff; assert (x220 == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x223 = S.fmul (fsquare_times x220 3) x3 in fsquare_times_lemma x220 3; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x8 0x7; assert (x223 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let r0 = S.fmul (fsquare_times x223 23) x22 in fsquare_times_lemma x223 23; assert_norm (pow2 23 = 0x800000); lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x800000 0x3fffff; assert (r0 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime) // S.prime - 2 = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d val finv_lemma: f:S.felem -> Lemma (finv f == M.pow f (S.prime - 2) % S.prime) let finv_lemma f = lemma_pow_mod_1 f; let r0, x2 = fexp_223_23 f in fexp_223_23_lemma f; let r1 = S.fmul (fsquare_times r0 5) f in fsquare_times_lemma r0 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff 0x20 0x1; assert (r1 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 % S.prime); let r2 = S.fmul (fsquare_times r1 3) x2 in fsquare_times_lemma r1 3; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffe1 0x8 0x3; assert (r2 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b % S.prime); let r = S.fmul (fsquare_times r2 2) f in fsquare_times_lemma r2 2; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0b 0x4 0x1; assert (r == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d % S.prime) val finv_is_finv_lemma: f:S.felem -> Lemma (finv f == S.finv f) let finv_is_finv_lemma f = finv_lemma f; assert (finv f == M.pow f (S.prime - 2) % S.prime); M.lemma_pow_mod #S.prime f (S.prime - 2) val fsqrt_lemma: f:S.felem -> Lemma (fsqrt f == M.pow f ((S.prime + 1) / 4) % S.prime)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fsqrt_lemma: f:S.felem -> Lemma (fsqrt f == M.pow f ((S.prime + 1) / 4) % S.prime)
[]
Hacl.Spec.K256.Finv.fsqrt_lemma
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.Finv.fsqrt f == Lib.NatMod.pow f ((Spec.K256.PointOps.prime + 1) / 4) % Spec.K256.PointOps.prime)
{ "end_col": 103, "end_line": 264, "start_col": 2, "start_line": 248 }
FStar.Pervasives.Lemma
val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.prime) b % S.prime; (==) { M.lemma_pow_mod_base (M.pow f a) b S.prime } M.pow (M.pow f a) b % S.prime; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.prime; }
val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime) let lemma_pow_pow_mod f a b =
false
null
true
calc ( == ) { M.pow (M.pow f a % S.prime) b % S.prime; ( == ) { M.lemma_pow_mod_base (M.pow f a) b S.prime } M.pow (M.pow f a) b % S.prime; ( == ) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.prime; }
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "Prims.nat", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.prime", "FStar.Mul.op_Star", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Lib.NatMod.lemma_pow_mod_base", "Prims.squash", "Lib.NatMod.lemma_pow_mul" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 = S.fmul f f = f2 val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime) val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime) let lemma_pow_mod_mul f a b = calc (==) { S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.prime) S.prime; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.prime } M.pow f a * M.pow f b % S.prime; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.prime; } val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime)
[]
Hacl.Spec.K256.Finv.lemma_pow_pow_mod
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> a: Prims.nat -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Lib.NatMod.pow (Lib.NatMod.pow f a % Spec.K256.PointOps.prime) b % Spec.K256.PointOps.prime == Lib.NatMod.pow f (a * b) % Spec.K256.PointOps.prime)
{ "end_col": 5, "end_line": 122, "start_col": 2, "start_line": 116 }
FStar.Pervasives.Lemma
val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_pow_mod_mul f a b = calc (==) { S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.prime) S.prime; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.prime } M.pow f a * M.pow f b % S.prime; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.prime; }
val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime) let lemma_pow_mod_mul f a b =
false
null
true
calc ( == ) { S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime); ( == ) { (Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.prime) S.prime; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.prime) } M.pow f a * M.pow f b % S.prime; ( == ) { M.lemma_pow_add f a b } M.pow f (a + b) % S.prime; }
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "Prims.nat", "FStar.Calc.calc_finish", "Prims.eq2", "Spec.K256.PointOps.fmul", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.prime", "Prims.op_Addition", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "Prims.squash", "Lib.NatMod.lemma_pow_add" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 = S.fmul f f = f2 val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime) val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime)
[]
Hacl.Spec.K256.Finv.lemma_pow_mod_mul
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> a: Prims.nat -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Spec.K256.PointOps.fmul (Lib.NatMod.pow f a % Spec.K256.PointOps.prime) (Lib.NatMod.pow f b % Spec.K256.PointOps.prime) == Lib.NatMod.pow f (a + b) % Spec.K256.PointOps.prime)
{ "end_col": 3, "end_line": 110, "start_col": 2, "start_line": 102 }
FStar.Pervasives.Lemma
val fexp_223_23_lemma: f:S.felem -> Lemma (let (r, x2) = fexp_223_23 f in x2 == M.pow f 0x3 % S.prime /\ r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fexp_223_23_lemma f = let x2 = S.fmul (fsquare_times f 1) f in fsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x2 == M.pow f 0x3 % S.prime); let x3 = S.fmul (fsquare_times x2 1) f in fsquare_times_lemma x2 1; lemma_pow_mod_1 f; lemma_pow_pow_mod_mul f 0x3 0x2 0x1; assert (x3 == M.pow f 0x7 % S.prime); let x6 = S.fmul (fsquare_times x3 3) x3 in fsquare_times_lemma x3 3; assert_norm (pow2 3 = 8); lemma_pow_pow_mod_mul f 0x7 0x8 0x7; assert (x6 == M.pow f 0x3f % S.prime); let x9 = S.fmul (fsquare_times x6 3) x3 in fsquare_times_lemma x6 3; lemma_pow_pow_mod_mul f 0x3f 0x8 0x7; assert (x9 == M.pow f 0x1ff % S.prime); let x11 = S.fmul (fsquare_times x9 2) x2 in fsquare_times_lemma x9 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0x1ff 0x4 0x3; assert (x11 == M.pow f 0x7ff % S.prime); let x22 = S.fmul (fsquare_times x11 11) x11 in fsquare_times_lemma x11 11; assert_norm (pow2 11 = 0x800); lemma_pow_pow_mod_mul f 0x7ff 0x800 0x7ff; assert (x22 == M.pow f 0x3fffff % S.prime); let x44 = S.fmul (fsquare_times x22 22) x22 in fsquare_times_lemma x22 22; assert_norm (pow2 22 = 0x400000); lemma_pow_pow_mod_mul f 0x3fffff 0x400000 0x3fffff; assert (x44 == M.pow f 0xfffffffffff % S.prime); let x88 = S.fmul (fsquare_times x44 44) x44 in fsquare_times_lemma x44 44; assert_norm (pow2 44 = 0x100000000000); lemma_pow_pow_mod_mul f 0xfffffffffff 0x100000000000 0xfffffffffff; assert (x88 == M.pow f 0xffffffffffffffffffffff % S.prime); let x176 = S.fmul (fsquare_times x88 88) x88 in fsquare_times_lemma x88 88; assert_norm (pow2 88 = 0x10000000000000000000000); lemma_pow_pow_mod_mul f 0xffffffffffffffffffffff 0x10000000000000000000000 0xffffffffffffffffffffff; assert (x176 == M.pow f 0xffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x220 = S.fmul (fsquare_times x176 44) x44 in fsquare_times_lemma x176 44; lemma_pow_pow_mod_mul f 0xffffffffffffffffffffffffffffffffffffffffffff 0x100000000000 0xfffffffffff; assert (x220 == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x223 = S.fmul (fsquare_times x220 3) x3 in fsquare_times_lemma x220 3; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x8 0x7; assert (x223 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let r0 = S.fmul (fsquare_times x223 23) x22 in fsquare_times_lemma x223 23; assert_norm (pow2 23 = 0x800000); lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x800000 0x3fffff; assert (r0 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime)
val fexp_223_23_lemma: f:S.felem -> Lemma (let (r, x2) = fexp_223_23 f in x2 == M.pow f 0x3 % S.prime /\ r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime) let fexp_223_23_lemma f =
false
null
true
let x2 = S.fmul (fsquare_times f 1) f in fsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x2 == M.pow f 0x3 % S.prime); let x3 = S.fmul (fsquare_times x2 1) f in fsquare_times_lemma x2 1; lemma_pow_mod_1 f; lemma_pow_pow_mod_mul f 0x3 0x2 0x1; assert (x3 == M.pow f 0x7 % S.prime); let x6 = S.fmul (fsquare_times x3 3) x3 in fsquare_times_lemma x3 3; assert_norm (pow2 3 = 8); lemma_pow_pow_mod_mul f 0x7 0x8 0x7; assert (x6 == M.pow f 0x3f % S.prime); let x9 = S.fmul (fsquare_times x6 3) x3 in fsquare_times_lemma x6 3; lemma_pow_pow_mod_mul f 0x3f 0x8 0x7; assert (x9 == M.pow f 0x1ff % S.prime); let x11 = S.fmul (fsquare_times x9 2) x2 in fsquare_times_lemma x9 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0x1ff 0x4 0x3; assert (x11 == M.pow f 0x7ff % S.prime); let x22 = S.fmul (fsquare_times x11 11) x11 in fsquare_times_lemma x11 11; assert_norm (pow2 11 = 0x800); lemma_pow_pow_mod_mul f 0x7ff 0x800 0x7ff; assert (x22 == M.pow f 0x3fffff % S.prime); let x44 = S.fmul (fsquare_times x22 22) x22 in fsquare_times_lemma x22 22; assert_norm (pow2 22 = 0x400000); lemma_pow_pow_mod_mul f 0x3fffff 0x400000 0x3fffff; assert (x44 == M.pow f 0xfffffffffff % S.prime); let x88 = S.fmul (fsquare_times x44 44) x44 in fsquare_times_lemma x44 44; assert_norm (pow2 44 = 0x100000000000); lemma_pow_pow_mod_mul f 0xfffffffffff 0x100000000000 0xfffffffffff; assert (x88 == M.pow f 0xffffffffffffffffffffff % S.prime); let x176 = S.fmul (fsquare_times x88 88) x88 in fsquare_times_lemma x88 88; assert_norm (pow2 88 = 0x10000000000000000000000); lemma_pow_pow_mod_mul f 0xffffffffffffffffffffff 0x10000000000000000000000 0xffffffffffffffffffffff; assert (x176 == M.pow f 0xffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x220 = S.fmul (fsquare_times x176 44) x44 in fsquare_times_lemma x176 44; lemma_pow_pow_mod_mul f 0xffffffffffffffffffffffffffffffffffffffffffff 0x100000000000 0xfffffffffff; assert (x220 == M.pow f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let x223 = S.fmul (fsquare_times x220 3) x3 in fsquare_times_lemma x220 3; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x8 0x7; assert (x223 == M.pow f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff % S.prime); let r0 = S.fmul (fsquare_times x223 23) x22 in fsquare_times_lemma x223 23; assert_norm (pow2 23 = 0x800000); lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x800000 0x3fffff; assert (r0 == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime)
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.prime", "Prims.unit", "Hacl.Spec.K256.Finv.lemma_pow_pow_mod_mul", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.pow2", "Hacl.Spec.K256.Finv.fsquare_times_lemma", "Spec.K256.PointOps.fmul", "Hacl.Spec.K256.Finv.fsquare_times", "Hacl.Spec.K256.Finv.lemma_pow_mod_1", "Hacl.Spec.K256.Finv.lemma_pow_mod_mul" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 = S.fmul f f = f2 val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime) val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime) let lemma_pow_mod_mul f a b = calc (==) { S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.prime) S.prime; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.prime } M.pow f a * M.pow f b % S.prime; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.prime; } val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime) let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.prime) b % S.prime; (==) { M.lemma_pow_mod_base (M.pow f a) b S.prime } M.pow (M.pow f a) b % S.prime; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.prime; } val lemma_pow_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> c:nat -> Lemma (S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime) == M.pow f (a * b + c) % S.prime) let lemma_pow_pow_mod_mul f a b c = calc (==) { S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_pow_mod f a b } S.fmul (M.pow f (a * b) % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.prime; } val fexp_223_23_lemma: f:S.felem -> Lemma (let (r, x2) = fexp_223_23 f in x2 == M.pow f 0x3 % S.prime /\ r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fexp_223_23_lemma: f:S.felem -> Lemma (let (r, x2) = fexp_223_23 f in x2 == M.pow f 0x3 % S.prime /\ r == M.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % S.prime)
[]
Hacl.Spec.K256.Finv.fexp_223_23_lemma
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.K256.Finv.fexp_223_23 f in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r x2 = _ in x2 == Lib.NatMod.pow f 0x3 % Spec.K256.PointOps.prime /\ r == Lib.NatMod.pow f 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff % Spec.K256.PointOps.prime) <: Type0))
{ "end_col": 99, "end_line": 211, "start_col": 25, "start_line": 142 }
FStar.Pervasives.Lemma
val lemma_pow_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> c:nat -> Lemma (S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime) == M.pow f (a * b + c) % S.prime)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_pow_pow_mod_mul f a b c = calc (==) { S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_pow_mod f a b } S.fmul (M.pow f (a * b) % S.prime) (M.pow f c % S.prime); (==) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.prime; }
val lemma_pow_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> c:nat -> Lemma (S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime) == M.pow f (a * b + c) % S.prime) let lemma_pow_pow_mod_mul f a b c =
false
null
true
calc ( == ) { S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime); ( == ) { lemma_pow_pow_mod f a b } S.fmul (M.pow f (a * b) % S.prime) (M.pow f c % S.prime); ( == ) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.prime; }
{ "checked_file": "Hacl.Spec.K256.Finv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Finv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.felem", "Prims.nat", "FStar.Calc.calc_finish", "Prims.eq2", "Spec.K256.PointOps.fmul", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.prime", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.K256.Finv.lemma_pow_pow_mod", "Prims.squash", "Hacl.Spec.K256.Finv.lemma_pow_mod_mul" ]
[]
module Hacl.Spec.K256.Finv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.prime let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.felem = { SE.a_spec = S.felem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.felem) -> x); } val one_mod : SE.one_st S.felem mk_to_nat_mod_comm_monoid let one_mod _ = S.one val mul_mod : SE.mul_st S.felem mk_to_nat_mod_comm_monoid let mul_mod x y = S.fmul x y val sqr_mod : SE.sqr_st S.felem mk_to_nat_mod_comm_monoid let sqr_mod x = S.fmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.felem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let fsquare_times (a:S.felem) (b:nat) : S.felem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val fsquare_times_lemma: a:S.felem -> b:nat -> Lemma (fsquare_times a b == M.pow a (pow2 b) % S.prime) let fsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (fsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.prime a (pow2 b) val fexp_223_23: f:S.felem -> tuple2 S.felem S.felem let fexp_223_23 f = let x2 = S.fmul (fsquare_times f 1) f in let x3 = S.fmul (fsquare_times x2 1) f in let x6 = S.fmul (fsquare_times x3 3) x3 in let x9 = S.fmul (fsquare_times x6 3) x3 in let x11 = S.fmul (fsquare_times x9 2) x2 in let x22 = S.fmul (fsquare_times x11 11) x11 in let x44 = S.fmul (fsquare_times x22 22) x22 in let x88 = S.fmul (fsquare_times x44 44) x44 in let x176 = S.fmul (fsquare_times x88 88) x88 in let x220 = S.fmul (fsquare_times x176 44) x44 in let x223 = S.fmul (fsquare_times x220 3) x3 in let r = S.fmul (fsquare_times x223 23) x22 in r, x2 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val finv: f:S.felem -> S.felem let finv f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 5) f in let r = S.fmul (fsquare_times r 3) x2 in let r = S.fmul (fsquare_times r 2) f in r val fsqrt: f:S.felem -> S.felem let fsqrt f = let r, x2 = fexp_223_23 f in let r = S.fmul (fsquare_times r 6) x2 in let r = fsquare_times r 2 in r val is_fsqrt: f:S.felem -> f2:S.felem -> bool let is_fsqrt f f2 = S.fmul f f = f2 val lemma_pow_mod_1: f:S.felem -> Lemma (f == M.pow f 1 % S.prime) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.prime; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.prime) val lemma_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> Lemma (S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime) == M.pow f (a + b) % S.prime) let lemma_pow_mod_mul f a b = calc (==) { S.fmul (M.pow f a % S.prime) (M.pow f b % S.prime); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.prime) S.prime; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.prime } M.pow f a * M.pow f b % S.prime; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.prime; } val lemma_pow_pow_mod: f:S.felem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.prime) b % S.prime == M.pow f (a * b) % S.prime) let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.prime) b % S.prime; (==) { M.lemma_pow_mod_base (M.pow f a) b S.prime } M.pow (M.pow f a) b % S.prime; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.prime; } val lemma_pow_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> c:nat -> Lemma (S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime) == M.pow f (a * b + c) % S.prime)
false
false
Hacl.Spec.K256.Finv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_pow_pow_mod_mul: f:S.felem -> a:nat -> b:nat -> c:nat -> Lemma (S.fmul (M.pow (M.pow f a % S.prime) b % S.prime) (M.pow f c % S.prime) == M.pow f (a * b + c) % S.prime)
[]
Hacl.Spec.K256.Finv.lemma_pow_pow_mod_mul
{ "file_name": "code/k256/Hacl.Spec.K256.Finv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.felem -> a: Prims.nat -> b: Prims.nat -> c: Prims.nat -> FStar.Pervasives.Lemma (ensures Spec.K256.PointOps.fmul (Lib.NatMod.pow (Lib.NatMod.pow f a % Spec.K256.PointOps.prime) b % Spec.K256.PointOps.prime) (Lib.NatMod.pow f c % Spec.K256.PointOps.prime) == Lib.NatMod.pow f (a * b + c) % Spec.K256.PointOps.prime)
{ "end_col": 3, "end_line": 134, "start_col": 2, "start_line": 128 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let block_len a = Hacl.Hash.Definitions.block_len a
let block_len a =
false
null
false
Hacl.Hash.Definitions.block_len a
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.hash_alg", "Hacl.Hash.Definitions.block_len", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.op_disEquality", "Lib.IntTypes.v", "Spec.Hash.Definitions.block_length" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val block_len : a: Spec.Hash.Definitions.hash_alg -> n: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v n = Spec.Hash.Definitions.block_length a}
[]
EverCrypt.Hash.Incremental.block_len
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.hash_alg -> n: Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB {Lib.IntTypes.v n = Spec.Hash.Definitions.block_length a}
{ "end_col": 51, "end_line": 78, "start_col": 18, "start_line": 78 }
Prims.GTot
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let hashed #a (h: HS.mem) (s: state a) = F.seen evercrypt_hash a h s
let hashed #a (h: HS.mem) (s: state a) =
false
null
false
F.seen evercrypt_hash a h s
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "sometrivial" ]
[ "EverCrypt.Hash.alg", "FStar.Monotonic.HyperStack.mem", "EverCrypt.Hash.Incremental.state", "Hacl.Streaming.Functor.seen", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Hacl.Streaming.Functor.bytes" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit) private let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit) private let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit) private let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit) private let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) private let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) private let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit) private let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit) private let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit) private let finish_blake2b: finish_st Blake2B = F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit) [@@ Comment "Perform a run-time test to determine which algorithm was chosen for the given piece of state."] let alg_of_state (a: G.erased Hash.alg) = F.index_of_state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) [@@ Comment "Write the resulting hash into `dst`, an array whose length is algorithm-specific. You can use the macros defined earlier in this file to allocate a destination buffer of the right length. The state remains valid after a call to `finish`, meaning the user may feed more data into the hash via `update`. (The finish function operates on an internal copy of the state and therefore does not invalidate the client-held state.)"] val finish: a:G.erased Hash.alg -> finish_st a let finish a s dst l = let a = alg_of_state a s in match a with | MD5 -> finish_md5 s dst l | SHA1 -> finish_sha1 s dst l | SHA2_224 -> finish_sha224 s dst l | SHA2_256 -> finish_sha256 s dst l | SHA2_384 -> finish_sha384 s dst l | SHA2_512 -> finish_sha512 s dst l | SHA3_224 -> finish_sha3_224 s dst l | SHA3_256 -> finish_sha3_256 s dst l | SHA3_384 -> finish_sha3_384 s dst l | SHA3_512 -> finish_sha3_512 s dst l | Blake2S -> finish_blake2s s dst l | Blake2B -> finish_blake2b s dst l [@@ Comment "Free a state previously allocated with `create_in`."] let free (i: G.erased Hash.alg) = F.free evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) // Private API (one-shot, multiplexing) // ------------------------------------ private val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 // A full one-shot hash that relies on vale at each multiplexing point let hash_256 input input_len dst = let open EverCrypt.Hash in // TODO: This function now only exists for SHA1 and MD5 Hacl.Hash.MD.mk_hash SHA2_256 Hacl.Hash.SHA2.alloca_256 update_multi_256 Hacl.Hash.SHA2.update_last_256 Hacl.Hash.SHA2.finish_256 input input_len dst private val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 input input_len dst = let open EverCrypt.Hash in Hacl.Hash.MD.mk_hash SHA2_224 Hacl.Hash.SHA2.alloca_224 update_multi_224 Hacl.Hash.SHA2.update_last_224 Hacl.Hash.SHA2.finish_224 input input_len dst // Public API (one-shot, agile and multiplexing) // --------------------------------------------- // NOTE: this function goes through all the Hacl.Hash.* wrappers which export // the correct agile low-level type, and thus does not need to be aware of the // implementation of Spec.Agile.Hash (no friend-ing). // // ALSO: for some reason, this function was historically exported with an order // of arguments different from Hacl.Hash.Definitions.hash_st a. Would be worth // fixing at some point. [@@ Comment "Hash `input`, of len `len`, into `dst`, an array whose length is determined by your choice of algorithm `a` (see Hacl_Spec.h). You can use the macros defined earlier in this file to allocate a destination buffer of the right length. This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. "] val hash: a:Hash.alg -> dst:B.buffer Lib.IntTypes.uint8 {B.length dst = hash_length a} -> input:B.buffer Lib.IntTypes.uint8 -> len:FStar.UInt32.t {B.length input = FStar.UInt32.v len /\ FStar.UInt32.v len `less_than_max_input_length` a} -> Stack unit (requires fun h0 -> B.live h0 dst /\ B.live h0 input /\ B.(loc_disjoint (loc_buffer input) (loc_buffer dst))) (ensures fun h0 _ h1 -> B.(modifies (loc_buffer dst) h0 h1) /\ B.as_seq h1 dst == Spec.Agile.Hash.hash a (B.as_seq h0 input)) let hash a dst input len = match a with | MD5 -> Hacl.Hash.MD5.legacy_hash input len dst | SHA1 -> Hacl.Hash.SHA1.legacy_hash input len dst | SHA2_224 -> hash_224 input len dst | SHA2_256 -> hash_256 input len dst | SHA2_384 -> Hacl.Streaming.SHA2.hash_384 input len dst | SHA2_512 -> Hacl.Streaming.SHA2.hash_512 input len dst | SHA3_224 -> Hacl.Hash.SHA3.hash SHA3_224 input len dst | SHA3_256 -> Hacl.Hash.SHA3.hash SHA3_256 input len dst | SHA3_384 -> Hacl.Hash.SHA3.hash SHA3_384 input len dst | SHA3_512 -> Hacl.Hash.SHA3.hash SHA3_512 input len dst | Blake2S -> if EverCrypt.TargetConfig.hacl_can_compile_vec128 then let vec128 = EverCrypt.AutoConfig2.has_vec128 () in if vec128 then Hacl.Hash.Blake2.hash_blake2s_128 input len dst else Hacl.Hash.Blake2.hash_blake2s_32 input len dst else Hacl.Hash.Blake2.hash_blake2s_32 input len dst | Blake2B -> if EverCrypt.TargetConfig.hacl_can_compile_vec256 then let vec256 = EverCrypt.AutoConfig2.has_vec256 () in if vec256 then Hacl.Hash.Blake2.hash_blake2b_256 input len dst else Hacl.Hash.Blake2.hash_blake2b_32 input len dst else Hacl.Hash.Blake2.hash_blake2b_32 input len dst // Public API (verified clients) // ----------------------------- /// Finally, a few helpers predicates to make things easier for clients... inline_for_extraction noextract let state (a: Hash.alg) = F.state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) inline_for_extraction noextract
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hashed : h: FStar.Monotonic.HyperStack.mem -> s: EverCrypt.Hash.Incremental.state a -> Prims.GTot Hacl.Streaming.Functor.bytes
[]
EverCrypt.Hash.Incremental.hashed
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> s: EverCrypt.Hash.Incremental.state a -> Prims.GTot Hacl.Streaming.Functor.bytes
{ "end_col": 29, "end_line": 348, "start_col": 2, "start_line": 348 }
FStar.HyperStack.ST.Stack
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
let init (a: G.erased Hash.alg) =
false
null
false
F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[]
[ "FStar.Ghost.erased", "EverCrypt.Hash.alg", "Hacl.Streaming.Functor.init", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "EverCrypt.Hash.state", "FStar.Ghost.reveal", "Prims.unit", "Hacl.Streaming.Functor.state", "FStar.Ghost.hide", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Hacl.Streaming.Interface.__proj__Stateful__item__invariant", "Hacl.Streaming.Interface.__proj__Block__item__key", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Streaming.Interface.__proj__Stateful__item__footprint", "Hacl.Streaming.Functor.footprint", "Hacl.Streaming.Functor.invariant", "Prims.eq2", "FStar.Seq.Base.seq", "Hacl.Streaming.Functor.uint8", "Hacl.Streaming.Functor.seen", "FStar.Seq.Base.empty", "Hacl.Streaming.Interface.__proj__Stateful__item__t", "Hacl.Streaming.Functor.key", "Hacl.Streaming.Interface.__proj__Stateful__item__v", "LowStar.Monotonic.Buffer.loc", "LowStar.Monotonic.Buffer.modifies", "Hacl.Streaming.Functor.preserves_freeable" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val init : a: FStar.Ghost.erased EverCrypt.Hash.alg -> s: Hacl.Streaming.Functor.state EverCrypt.Hash.Incremental.evercrypt_hash (FStar.Ghost.reveal (FStar.Ghost.hide (FStar.Ghost.reveal a))) (EverCrypt.Hash.state (FStar.Ghost.reveal a)) (FStar.Ghost.erased Prims.unit) -> FStar.HyperStack.ST.Stack Prims.unit
[]
EverCrypt.Hash.Incremental.init
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: FStar.Ghost.erased EverCrypt.Hash.alg -> s: Hacl.Streaming.Functor.state EverCrypt.Hash.Incremental.evercrypt_hash (FStar.Ghost.reveal (FStar.Ghost.hide (FStar.Ghost.reveal a))) (EverCrypt.Hash.state (FStar.Ghost.reveal a)) (FStar.Ghost.erased Prims.unit) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 101, "end_line": 167, "start_col": 34, "start_line": 167 }
FStar.HyperStack.ST.ST
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
let create_in a =
false
null
false
F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[]
[ "Spec.Hash.Definitions.fixed_len_alg", "Hacl.Streaming.Functor.create_in", "EverCrypt.Hash.Incremental.evercrypt_hash", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit", "FStar.Monotonic.HyperHeap.rid", "Hacl.Streaming.Functor.state", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Hacl.Streaming.Interface.__proj__Stateful__item__invariant", "Hacl.Streaming.Interface.__proj__Block__item__key", "FStar.HyperStack.ST.is_eternal_region", "Hacl.Streaming.Functor.invariant", "Hacl.Streaming.Functor.freeable", "Prims.eq2", "FStar.Seq.Base.seq", "Hacl.Streaming.Functor.uint8", "Hacl.Streaming.Functor.seen", "FStar.Seq.Base.empty", "Hacl.Streaming.Interface.__proj__Stateful__item__t", "Hacl.Streaming.Functor.key", "Hacl.Streaming.Interface.__proj__Stateful__item__v", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "LowStar.Monotonic.Buffer.fresh_loc", "Hacl.Streaming.Functor.footprint", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.loc_region_only" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val create_in : a: Spec.Hash.Definitions.fixed_len_alg -> r: FStar.Monotonic.HyperHeap.rid -> FStar.HyperStack.ST.ST (Hacl.Streaming.Functor.state EverCrypt.Hash.Incremental.evercrypt_hash a (EverCrypt.Hash.state a) (FStar.Ghost.erased Prims.unit))
[]
EverCrypt.Hash.Incremental.create_in
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.fixed_len_alg -> r: FStar.Monotonic.HyperHeap.rid -> FStar.HyperStack.ST.ST (Hacl.Streaming.Functor.state EverCrypt.Hash.Incremental.evercrypt_hash a (EverCrypt.Hash.state a) (FStar.Ghost.erased Prims.unit))
{ "end_col": 90, "end_line": 163, "start_col": 18, "start_line": 163 }
FStar.HyperStack.ST.Stack
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let alg_of_state (a: G.erased Hash.alg) = F.index_of_state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
let alg_of_state (a: G.erased Hash.alg) =
true
null
false
F.index_of_state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[]
[ "FStar.Ghost.erased", "EverCrypt.Hash.alg", "Hacl.Streaming.Functor.index_of_state", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "EverCrypt.Hash.state", "FStar.Ghost.reveal", "Prims.unit", "Hacl.Streaming.Functor.state", "FStar.Monotonic.HyperStack.mem", "Hacl.Streaming.Functor.invariant", "Prims.l_and", "Prims.eq2" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit) private let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit) private let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit) private let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit) private let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) private let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) private let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit) private let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit) private let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit) private let finish_blake2b: finish_st Blake2B = F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit) [@@ Comment
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val alg_of_state : a: FStar.Ghost.erased EverCrypt.Hash.alg -> s: Hacl.Streaming.Functor.state EverCrypt.Hash.Incremental.evercrypt_hash (FStar.Ghost.reveal a) (EverCrypt.Hash.state (FStar.Ghost.reveal a)) (FStar.Ghost.erased Prims.unit) -> FStar.HyperStack.ST.Stack Spec.Hash.Definitions.fixed_len_alg
[]
EverCrypt.Hash.Incremental.alg_of_state
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: FStar.Ghost.erased EverCrypt.Hash.alg -> s: Hacl.Streaming.Functor.state EverCrypt.Hash.Incremental.evercrypt_hash (FStar.Ghost.reveal a) (EverCrypt.Hash.state (FStar.Ghost.reveal a)) (FStar.Ghost.erased Prims.unit) -> FStar.HyperStack.ST.Stack Spec.Hash.Definitions.fixed_len_alg
{ "end_col": 116, "end_line": 227, "start_col": 42, "start_line": 227 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
let finish_st a =
false
null
false
F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.fixed_len_alg", "Hacl.Streaming.Functor.finish_st", "EverCrypt.Hash.Incremental.evercrypt_hash", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish_st : a: Spec.Hash.Definitions.fixed_len_alg -> Type0
[]
EverCrypt.Hash.Incremental.finish_st
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.fixed_len_alg -> Type0
{ "end_col": 87, "end_line": 196, "start_col": 18, "start_line": 196 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let free (i: G.erased Hash.alg) = F.free evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)
let free (i: G.erased Hash.alg) =
false
null
false
F.free evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "EverCrypt.Hash.alg", "Hacl.Streaming.Functor.free", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "EverCrypt.Hash.state", "FStar.Ghost.reveal", "Prims.unit", "Hacl.Streaming.Functor.free_st" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit) private let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit) private let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit) private let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit) private let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) private let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) private let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit) private let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit) private let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit) private let finish_blake2b: finish_st Blake2B = F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit) [@@ Comment "Perform a run-time test to determine which algorithm was chosen for the given piece of state."] let alg_of_state (a: G.erased Hash.alg) = F.index_of_state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) [@@ Comment "Write the resulting hash into `dst`, an array whose length is algorithm-specific. You can use the macros defined earlier in this file to allocate a destination buffer of the right length. The state remains valid after a call to `finish`, meaning the user may feed more data into the hash via `update`. (The finish function operates on an internal copy of the state and therefore does not invalidate the client-held state.)"] val finish: a:G.erased Hash.alg -> finish_st a let finish a s dst l = let a = alg_of_state a s in match a with | MD5 -> finish_md5 s dst l | SHA1 -> finish_sha1 s dst l | SHA2_224 -> finish_sha224 s dst l | SHA2_256 -> finish_sha256 s dst l | SHA2_384 -> finish_sha384 s dst l | SHA2_512 -> finish_sha512 s dst l | SHA3_224 -> finish_sha3_224 s dst l | SHA3_256 -> finish_sha3_256 s dst l | SHA3_384 -> finish_sha3_384 s dst l | SHA3_512 -> finish_sha3_512 s dst l | Blake2S -> finish_blake2s s dst l | Blake2B -> finish_blake2b s dst l [@@ Comment
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val free : i: FStar.Ghost.erased EverCrypt.Hash.alg -> Hacl.Streaming.Functor.free_st EverCrypt.Hash.Incremental.evercrypt_hash (FStar.Ghost.reveal i) (EverCrypt.Hash.state (FStar.Ghost.reveal i)) (FStar.Ghost.erased Prims.unit)
[]
EverCrypt.Hash.Incremental.free
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: FStar.Ghost.erased EverCrypt.Hash.alg -> Hacl.Streaming.Functor.free_st EverCrypt.Hash.Incremental.evercrypt_hash (FStar.Ghost.reveal i) (EverCrypt.Hash.state (FStar.Ghost.reveal i)) (FStar.Ghost.erased Prims.unit)
{ "end_col": 98, "end_line": 255, "start_col": 34, "start_line": 255 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_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: Hash.alg) = F.state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
let state (a: Hash.alg) =
false
null
false
F.state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "EverCrypt.Hash.alg", "Hacl.Streaming.Functor.state", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit) private let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit) private let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit) private let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit) private let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) private let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) private let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit) private let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit) private let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit) private let finish_blake2b: finish_st Blake2B = F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit) [@@ Comment "Perform a run-time test to determine which algorithm was chosen for the given piece of state."] let alg_of_state (a: G.erased Hash.alg) = F.index_of_state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) [@@ Comment "Write the resulting hash into `dst`, an array whose length is algorithm-specific. You can use the macros defined earlier in this file to allocate a destination buffer of the right length. The state remains valid after a call to `finish`, meaning the user may feed more data into the hash via `update`. (The finish function operates on an internal copy of the state and therefore does not invalidate the client-held state.)"] val finish: a:G.erased Hash.alg -> finish_st a let finish a s dst l = let a = alg_of_state a s in match a with | MD5 -> finish_md5 s dst l | SHA1 -> finish_sha1 s dst l | SHA2_224 -> finish_sha224 s dst l | SHA2_256 -> finish_sha256 s dst l | SHA2_384 -> finish_sha384 s dst l | SHA2_512 -> finish_sha512 s dst l | SHA3_224 -> finish_sha3_224 s dst l | SHA3_256 -> finish_sha3_256 s dst l | SHA3_384 -> finish_sha3_384 s dst l | SHA3_512 -> finish_sha3_512 s dst l | Blake2S -> finish_blake2s s dst l | Blake2B -> finish_blake2b s dst l [@@ Comment "Free a state previously allocated with `create_in`."] let free (i: G.erased Hash.alg) = F.free evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) // Private API (one-shot, multiplexing) // ------------------------------------ private val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 // A full one-shot hash that relies on vale at each multiplexing point let hash_256 input input_len dst = let open EverCrypt.Hash in // TODO: This function now only exists for SHA1 and MD5 Hacl.Hash.MD.mk_hash SHA2_256 Hacl.Hash.SHA2.alloca_256 update_multi_256 Hacl.Hash.SHA2.update_last_256 Hacl.Hash.SHA2.finish_256 input input_len dst private val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 let hash_224 input input_len dst = let open EverCrypt.Hash in Hacl.Hash.MD.mk_hash SHA2_224 Hacl.Hash.SHA2.alloca_224 update_multi_224 Hacl.Hash.SHA2.update_last_224 Hacl.Hash.SHA2.finish_224 input input_len dst // Public API (one-shot, agile and multiplexing) // --------------------------------------------- // NOTE: this function goes through all the Hacl.Hash.* wrappers which export // the correct agile low-level type, and thus does not need to be aware of the // implementation of Spec.Agile.Hash (no friend-ing). // // ALSO: for some reason, this function was historically exported with an order // of arguments different from Hacl.Hash.Definitions.hash_st a. Would be worth // fixing at some point. [@@ Comment "Hash `input`, of len `len`, into `dst`, an array whose length is determined by your choice of algorithm `a` (see Hacl_Spec.h). You can use the macros defined earlier in this file to allocate a destination buffer of the right length. This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. "] val hash: a:Hash.alg -> dst:B.buffer Lib.IntTypes.uint8 {B.length dst = hash_length a} -> input:B.buffer Lib.IntTypes.uint8 -> len:FStar.UInt32.t {B.length input = FStar.UInt32.v len /\ FStar.UInt32.v len `less_than_max_input_length` a} -> Stack unit (requires fun h0 -> B.live h0 dst /\ B.live h0 input /\ B.(loc_disjoint (loc_buffer input) (loc_buffer dst))) (ensures fun h0 _ h1 -> B.(modifies (loc_buffer dst) h0 h1) /\ B.as_seq h1 dst == Spec.Agile.Hash.hash a (B.as_seq h0 input)) let hash a dst input len = match a with | MD5 -> Hacl.Hash.MD5.legacy_hash input len dst | SHA1 -> Hacl.Hash.SHA1.legacy_hash input len dst | SHA2_224 -> hash_224 input len dst | SHA2_256 -> hash_256 input len dst | SHA2_384 -> Hacl.Streaming.SHA2.hash_384 input len dst | SHA2_512 -> Hacl.Streaming.SHA2.hash_512 input len dst | SHA3_224 -> Hacl.Hash.SHA3.hash SHA3_224 input len dst | SHA3_256 -> Hacl.Hash.SHA3.hash SHA3_256 input len dst | SHA3_384 -> Hacl.Hash.SHA3.hash SHA3_384 input len dst | SHA3_512 -> Hacl.Hash.SHA3.hash SHA3_512 input len dst | Blake2S -> if EverCrypt.TargetConfig.hacl_can_compile_vec128 then let vec128 = EverCrypt.AutoConfig2.has_vec128 () in if vec128 then Hacl.Hash.Blake2.hash_blake2s_128 input len dst else Hacl.Hash.Blake2.hash_blake2s_32 input len dst else Hacl.Hash.Blake2.hash_blake2s_32 input len dst | Blake2B -> if EverCrypt.TargetConfig.hacl_can_compile_vec256 then let vec256 = EverCrypt.AutoConfig2.has_vec256 () in if vec256 then Hacl.Hash.Blake2.hash_blake2b_256 input len dst else Hacl.Hash.Blake2.hash_blake2b_32 input len dst else Hacl.Hash.Blake2.hash_blake2b_32 input len dst // Public API (verified clients) // ----------------------------- /// Finally, a few helpers predicates to make things easier for clients...
false
true
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val state : a: EverCrypt.Hash.alg -> Type0
[]
EverCrypt.Hash.Incremental.state
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: EverCrypt.Hash.alg -> Type0
{ "end_col": 91, "end_line": 344, "start_col": 26, "start_line": 344 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
let hash_state =
false
null
false
F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Functor.state_s", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Spec.Hash.Definitions.SHA2_256", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "EverCrypt.Hash.Incremental.agile_state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hash_state : Type0
[]
EverCrypt.Hash.Incremental.hash_state
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 78, "end_line": 153, "start_col": 2, "start_line": 153 }
Prims.Tot
val agile_state:stateful Hash.alg
[ { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i)
val agile_state:stateful Hash.alg let agile_state:stateful Hash.alg =
false
null
false
Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Interface.Stateful", "EverCrypt.Hash.alg", "EverCrypt.Hash.state", "FStar.Monotonic.HyperStack.mem", "EverCrypt.Hash.footprint", "LowStar.Monotonic.Buffer.loc", "EverCrypt.Hash.freeable", "EverCrypt.Hash.invariant", "Spec.Hash.Definitions.words_state", "EverCrypt.Hash.repr", "EverCrypt.Hash.invariant_loc_in_footprint", "Prims.unit", "EverCrypt.Hash.frame_invariant_implies_footprint_preservation", "EverCrypt.Hash.frame_invariant", "EverCrypt.Hash.alloca", "EverCrypt.Hash.create_in", "FStar.Ghost.erased", "EverCrypt.Hash.free", "Prims.l_and", "LowStar.Monotonic.Buffer.modifies", "FStar.Ghost.reveal", "EverCrypt.Hash.copy", "LowStar.Monotonic.Buffer.loc_disjoint", "Prims.eq2", "Prims.l_imp" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract
false
true
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val agile_state:stateful Hash.alg
[]
EverCrypt.Hash.Incremental.agile_state
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Streaming.Interface.stateful Spec.Hash.Definitions.fixed_len_alg
{ "end_col": 37, "end_line": 52, "start_col": 2, "start_line": 34 }
Prims.Tot
val finish_blake2s:finish_st Blake2S
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit)
val finish_blake2s:finish_st Blake2S let finish_blake2s:finish_st Blake2S =
false
null
false
F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Functor.mk_finish", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Spec.Hash.Definitions.Blake2S", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit) private let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit) private let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit) private let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit) private let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) private let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) private let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit) private let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit)
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish_blake2s:finish_st Blake2S
[]
EverCrypt.Hash.Incremental.finish_blake2s
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.Blake2S
{ "end_col": 121, "end_line": 221, "start_col": 40, "start_line": 221 }
Prims.Tot
val finish: a:G.erased Hash.alg -> finish_st a
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish a s dst l = let a = alg_of_state a s in match a with | MD5 -> finish_md5 s dst l | SHA1 -> finish_sha1 s dst l | SHA2_224 -> finish_sha224 s dst l | SHA2_256 -> finish_sha256 s dst l | SHA2_384 -> finish_sha384 s dst l | SHA2_512 -> finish_sha512 s dst l | SHA3_224 -> finish_sha3_224 s dst l | SHA3_256 -> finish_sha3_256 s dst l | SHA3_384 -> finish_sha3_384 s dst l | SHA3_512 -> finish_sha3_512 s dst l | Blake2S -> finish_blake2s s dst l | Blake2B -> finish_blake2b s dst l
val finish: a:G.erased Hash.alg -> finish_st a let finish a s dst l =
false
null
false
let a = alg_of_state a s in match a with | MD5 -> finish_md5 s dst l | SHA1 -> finish_sha1 s dst l | SHA2_224 -> finish_sha224 s dst l | SHA2_256 -> finish_sha256 s dst l | SHA2_384 -> finish_sha384 s dst l | SHA2_512 -> finish_sha512 s dst l | SHA3_224 -> finish_sha3_224 s dst l | SHA3_256 -> finish_sha3_256 s dst l | SHA3_384 -> finish_sha3_384 s dst l | SHA3_512 -> finish_sha3_512 s dst l | Blake2S -> finish_blake2s s dst l | Blake2B -> finish_blake2b s dst l
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "EverCrypt.Hash.alg", "Hacl.Streaming.Functor.state", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "FStar.Ghost.reveal", "EverCrypt.Hash.state", "Prims.unit", "LowStar.Buffer.buffer", "Hacl.Streaming.Functor.uint8", "Hacl.Streaming.Interface.__proj__Block__item__output_length_t", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Hacl.Streaming.Interface.__proj__Block__item__output_length", "EverCrypt.Hash.Incremental.finish_md5", "EverCrypt.Hash.Incremental.finish_sha1", "EverCrypt.Hash.Incremental.finish_sha224", "EverCrypt.Hash.Incremental.finish_sha256", "EverCrypt.Hash.Incremental.finish_sha384", "EverCrypt.Hash.Incremental.finish_sha512", "EverCrypt.Hash.Incremental.finish_sha3_224", "EverCrypt.Hash.Incremental.finish_sha3_256", "EverCrypt.Hash.Incremental.finish_sha3_384", "EverCrypt.Hash.Incremental.finish_sha3_512", "EverCrypt.Hash.Incremental.finish_blake2s", "EverCrypt.Hash.Incremental.finish_blake2b", "EverCrypt.Hash.Incremental.alg_of_state" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit) private let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit) private let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit) private let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit) private let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) private let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) private let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit) private let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit) private let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit) private let finish_blake2b: finish_st Blake2B = F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit) [@@ Comment "Perform a run-time test to determine which algorithm was chosen for the given piece of state."] let alg_of_state (a: G.erased Hash.alg) = F.index_of_state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) [@@ Comment "Write the resulting hash into `dst`, an array whose length is algorithm-specific. You can use the macros defined earlier in this file to allocate a destination buffer of the right length. The state remains valid after a call to `finish`, meaning the user may feed more data into the hash via `update`. (The finish function operates on an internal copy of the state and therefore does not invalidate the client-held state.)"]
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish: a:G.erased Hash.alg -> finish_st a
[]
EverCrypt.Hash.Incremental.finish
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: FStar.Ghost.erased EverCrypt.Hash.alg -> EverCrypt.Hash.Incremental.finish_st (FStar.Ghost.reveal a)
{ "end_col": 37, "end_line": 251, "start_col": 22, "start_line": 237 }
Prims.Tot
val finish_sha256:finish_st SHA2_256
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
val finish_sha256:finish_st SHA2_256 let finish_sha256:finish_st SHA2_256 =
false
null
false
F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Functor.mk_finish", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Spec.Hash.Definitions.SHA2_256", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish_sha256:finish_st SHA2_256
[]
EverCrypt.Hash.Incremental.finish_sha256
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.SHA2_256
{ "end_col": 123, "end_line": 207, "start_col": 40, "start_line": 207 }
Prims.Tot
val finish_sha224:finish_st SHA2_224
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
val finish_sha224:finish_st SHA2_224 let finish_sha224:finish_st SHA2_224 =
false
null
false
F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Functor.mk_finish", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Spec.Hash.Definitions.SHA2_224", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish_sha224:finish_st SHA2_224
[]
EverCrypt.Hash.Incremental.finish_sha224
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.SHA2_224
{ "end_col": 123, "end_line": 205, "start_col": 40, "start_line": 205 }
Prims.Tot
val finish_sha3_256:finish_st SHA3_256
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit)
val finish_sha3_256:finish_st SHA3_256 let finish_sha3_256:finish_st SHA3_256 =
false
null
false
F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Functor.mk_finish", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Spec.Hash.Definitions.SHA3_256", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit) private let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit) private let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish_sha3_256:finish_st SHA3_256
[]
EverCrypt.Hash.Incremental.finish_sha3_256
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.SHA3_256
{ "end_col": 125, "end_line": 211, "start_col": 42, "start_line": 211 }
Prims.Tot
val finish_sha3_224:finish_st SHA3_224
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
val finish_sha3_224:finish_st SHA3_224 let finish_sha3_224:finish_st SHA3_224 =
false
null
false
F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Functor.mk_finish", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Spec.Hash.Definitions.SHA3_224", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit) private let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish_sha3_224:finish_st SHA3_224
[]
EverCrypt.Hash.Incremental.finish_sha3_224
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.SHA3_224
{ "end_col": 125, "end_line": 209, "start_col": 42, "start_line": 209 }
Prims.Tot
val finish_md5:finish_st MD5
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
val finish_md5:finish_st MD5 let finish_md5:finish_st MD5 =
false
null
false
F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Functor.mk_finish", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Spec.Hash.Definitions.MD5", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized.
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish_md5:finish_st MD5
[]
EverCrypt.Hash.Incremental.finish_md5
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.MD5
{ "end_col": 105, "end_line": 201, "start_col": 32, "start_line": 201 }
Prims.Tot
val finish_sha1:finish_st SHA1
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
val finish_sha1:finish_st SHA1 let finish_sha1:finish_st SHA1 =
false
null
false
F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Functor.mk_finish", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Spec.Hash.Definitions.SHA1", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish_sha1:finish_st SHA1
[]
EverCrypt.Hash.Incremental.finish_sha1
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.SHA1
{ "end_col": 109, "end_line": 203, "start_col": 34, "start_line": 203 }
Prims.Tot
val finish_sha512:finish_st SHA2_512
[ { "abbrev": false, "full_module": "EverCrypt.Hash.Incremental.Macros", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.Interface", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit)
val finish_sha512:finish_st SHA2_512 let finish_sha512:finish_st SHA2_512 =
false
null
false
F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit)
{ "checked_file": "EverCrypt.Hash.Incremental.fst.checked", "dependencies": [ "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.fsti.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Hash.SHA3.fsti.checked", "Hacl.Hash.SHA2.fsti.checked", "Hacl.Hash.SHA1.fsti.checked", "Hacl.Hash.MD5.fsti.checked", "Hacl.Hash.MD.fsti.checked", "Hacl.Hash.Definitions.fst.checked", "Hacl.Hash.Blake2.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Hash.Incremental.Macros.fst.checked", "EverCrypt.Hash.fsti.checked", "EverCrypt.Error.fsti.checked", "EverCrypt.AutoConfig2.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.Hash.Incremental.fst" }
[ "total" ]
[ "Hacl.Streaming.Functor.mk_finish", "Spec.Hash.Definitions.fixed_len_alg", "EverCrypt.Hash.Incremental.evercrypt_hash", "Spec.Hash.Definitions.SHA2_512", "EverCrypt.Hash.state", "FStar.Ghost.erased", "Prims.unit" ]
[]
module EverCrypt.Hash.Incremental open FStar.Mul // Watch out: keep the module declarations in sync between fsti and fst // (otherwise interleaving issues may bite). module B = LowStar.Buffer module S = FStar.Seq module ST = FStar.HyperStack.ST module HS = FStar.HyperStack module G = FStar.Ghost module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module Hash = EverCrypt.Hash open FStar.HyperStack.ST open Spec.Hash.Definitions open Hacl.Streaming.Interface include Spec.Hash.Definitions include Hacl.Hash.Definitions open Spec.Hash.Lemmas #set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0" // Definitions for instantiating the streaming functor // --------------------------------------------------- inline_for_extraction noextract let agile_state: stateful Hash.alg = Stateful EverCrypt.Hash.state (fun #i h s -> EverCrypt.Hash.footprint s h) EverCrypt.Hash.freeable (fun #i h s -> EverCrypt.Hash.invariant s h) Spec.Hash.Definitions.words_state (fun i h s -> EverCrypt.Hash.repr s h) (fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h) (fun #i l s h0 h1 -> EverCrypt.Hash.frame_invariant l s h0 h1; EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1) (fun #i l s h0 h1 -> ()) EverCrypt.Hash.alloca EverCrypt.Hash.create_in (fun i -> EverCrypt.Hash.free #i) (fun i -> EverCrypt.Hash.copy #i) include EverCrypt.Hash.Incremental.Macros #push-options "--ifuel 1" (* Adding some non-inlined definitions to factorize code. This one is public because it's used by the WASM API, and is generally useful to callers. *) let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) = match a with | MD5 -> md5_hash_len | SHA1 -> sha1_hash_len | SHA2_224 -> sha2_224_hash_len | SHA2_256 -> sha2_256_hash_len | SHA2_384 -> sha2_384_hash_len | SHA2_512 -> sha2_512_hash_len | SHA3_224 -> sha3_224_hash_len | SHA3_256 -> sha3_256_hash_len | SHA3_384 -> sha3_384_hash_len | SHA3_512 -> sha3_512_hash_len | Blake2S -> blake2s_hash_len | Blake2B -> blake2b_hash_len #pop-options private let block_len a = Hacl.Hash.Definitions.block_len a inline_for_extraction noextract let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Definitions.extra_state a = if is_blake a then i else () inline_for_extraction noextract let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }): Spec.Hash.Incremental.prev_length_t a = if is_keccak a then () else i #push-options "--z3rlimit 500" inline_for_extraction noextract let evercrypt_hash : block Hash.alg = Block Erased agile_state (stateful_unused Hash.alg) unit Hacl.Hash.Definitions.max_input_len64 (fun a () -> Spec.Hash.Definitions.hash_length a) block_len block_len // No vectorization (fun _ -> 0ul) (fun _ _ -> S.empty) (fun a _ -> Spec.Agile.Hash.init a) (fun a s prevlen input -> let prevlen = extra_state_of_nat a prevlen in Spec.Agile.Hash.update_multi a s prevlen input) (fun a s prevlen input -> let prevlen = prev_length_of_nat a prevlen in Spec.Hash.Incremental.update_last a s prevlen input) (fun a _ s () -> Spec.Agile.Hash.finish a s ()) (fun a _ s () -> Spec.Agile.Hash.hash a s) (fun a s prevlen -> if is_blake a then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s else Spec.Hash.Lemmas.update_multi_zero a s) (* update_multi_associative *) (fun a s prevlen1 prevlen2 input1 input2 -> if is_blake a then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2 else Spec.Hash.Lemmas.update_multi_associative a s input1 input2) (* spec_is_incremental *) (fun a _ input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); Spec.Hash.Incremental.hash_is_hash_incremental' a input ()) EverCrypt.Hash.alg_of_state (fun i _ _ -> EverCrypt.Hash.init #i) (fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len) (fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len) (fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) #pop-options let hash_state = F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit) // Public API (streaming) // ---------------------- [@@ Comment "Allocate initial state for the agile hash. The argument `a` stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling `free`."] let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Reset an existing state to the initial hash state with empty data."] let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) () [@@ Comment "Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to `update` (since the last call to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice."] let update (i: G.erased Hash.alg) (s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)) (data: B.buffer uint8) (len: UInt32.t): Stack EverCrypt.Error.error_code (requires fun h0 -> F.update_pre evercrypt_hash i s data len h0) (ensures fun h0 e h1 -> match e with | EverCrypt.Error.Success -> S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\ F.update_post evercrypt_hash i s data len h0 h1 | EverCrypt.Error.MaximumLengthExceeded -> h0 == h1 /\ not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i)) | _ -> False) = match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with | Hacl.Streaming.Types.Success -> EverCrypt.Error.Success | Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded inline_for_extraction noextract let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) /// The wrapper pattern, to ensure that the stack-allocated state is properly /// monomorphized. private let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit) private let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit) private let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit) private let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit) private let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit) private let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit) private let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) private let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) private let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit)
false
false
EverCrypt.Hash.Incremental.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finish_sha512:finish_st SHA2_512
[]
EverCrypt.Hash.Incremental.finish_sha512
{ "file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.SHA2_512
{ "end_col": 123, "end_line": 219, "start_col": 40, "start_line": 219 }