file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint8_to_uint16
val uint8_to_uint16 (x: U8.t) : (y: U16.t{U16.v y == U8.v x})
val uint8_to_uint16 (x: U8.t) : (y: U16.t{U16.v y == U8.v x})
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 617, "start_col": 0, "start_line": 616 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt8.t -> y: FStar.UInt16.t{FStar.UInt16.v y == FStar.UInt8.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t", "FStar.Int.Cast.uint8_to_uint16", "FStar.UInt16.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt16.n", "FStar.UInt8.n", "FStar.UInt16.v", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let uint8_to_uint16 (x: U8.t) : (y: U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_mul
val u64_mul (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size ((UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) UInt64.n)) (ensures fun z -> UInt64.v z == (UInt64.v x) `Prims.op_Multiply` (UInt64.v y))
val u64_mul (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size ((UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) UInt64.n)) (ensures fun z -> UInt64.v z == (UInt64.v x) `Prims.op_Multiply` (UInt64.v y))
let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 539, "start_col": 0, "start_line": 535 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt64.mul", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Multiply", "FStar.UInt64.v", "FStar.UInt64.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u64_mul (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size ((UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) UInt64.n)) (ensures fun z -> UInt64.v z == (UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) =
UInt64.mul x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_logxor
val u64_logxor (r: range) (x y: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> (UInt64.v x) `UInt.logxor` (UInt64.v y) == UInt64.v z))
val u64_logxor (r: range) (x y: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> (UInt64.v x) `UInt.logxor` (UInt64.v y) == UInt64.v z))
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 21, "end_line": 570, "start_col": 0, "start_line": 566 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt64.logxor", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt64.n", "FStar.UInt.logxor", "FStar.UInt64.v" ]
[]
false
false
false
false
false
let u64_logxor (r: range) (x y: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> (UInt64.v x) `UInt.logxor` (UInt64.v y) == UInt64.v z)) =
UInt64.logxor x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_lognot
val u64_lognot (r: range) (x: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
val u64_lognot (r: range) (x: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 19, "end_line": 586, "start_col": 0, "start_line": 582 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt64.lognot", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt64.n", "FStar.UInt.lognot", "FStar.UInt64.v" ]
[]
false
false
false
false
false
let u64_lognot (r: range) (x: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) =
UInt64.lognot x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_logor
val u64_logor (r: range) (x y: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> (UInt64.v x) `UInt.logor` (UInt64.v y) == UInt64.v z))
val u64_logor (r: range) (x y: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> (UInt64.v x) `UInt.logor` (UInt64.v y) == UInt64.v z))
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 20, "end_line": 578, "start_col": 0, "start_line": 574 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt64.logor", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt64.n", "FStar.UInt.logor", "FStar.UInt64.v" ]
[]
false
false
false
false
false
let u64_logor (r: range) (x y: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> (UInt64.v x) `UInt.logor` (UInt64.v y) == UInt64.v z)) =
UInt64.logor x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_add
val u64_add (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
val u64_add (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 525, "start_col": 0, "start_line": 521 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt64.add", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Addition", "FStar.UInt64.v", "FStar.UInt64.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u64_add (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) =
UInt64.add x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint32_to_uint64
val uint32_to_uint64 (x: U32.t) : (y: U64.t{U64.v y == U32.v x})
val uint32_to_uint64 (x: U32.t) : (y: U64.t{U64.v y == U32.v x})
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 35, "end_line": 637, "start_col": 0, "start_line": 636 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t -> y: FStar.UInt64.t{FStar.UInt64.v y == FStar.UInt32.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "FStar.Int.Cast.uint32_to_uint64", "FStar.UInt64.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt64.n", "FStar.UInt32.n", "FStar.UInt64.v", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let uint32_to_uint64 (x: U32.t) : (y: U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint16_to_uint8
val uint16_to_uint8 (x: U16.t{FStar.UInt.fits (U16.v x) 8}) : (y: U8.t{U8.v y == U16.v x})
val uint16_to_uint8 (x: U16.t{FStar.UInt.fits (U16.v x) 8}) : (y: U8.t{U8.v y == U16.v x})
let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint8 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 643, "start_col": 0, "start_line": 642 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x inline_for_extraction noextract let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x (** Narrowing casts, only when narrowing does not lose any precision **)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt16.t{FStar.UInt.fits (FStar.UInt16.v x) 8} -> y: FStar.UInt8.t{FStar.UInt8.v y == FStar.UInt16.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt16.t", "Prims.b2t", "FStar.UInt.fits", "FStar.UInt16.v", "FStar.Int.Cast.uint16_to_uint8", "FStar.UInt8.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "FStar.UInt16.n", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let uint16_to_uint8 (x: U16.t{FStar.UInt.fits (U16.v x) 8}) : (y: U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.qelem5
val qelem5 : Type0
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 10, "start_col": 0, "start_line": 10 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple5", "Lib.IntTypes.uint64" ]
[]
false
false
false
true
true
let qelem5 =
(uint64 & uint64 & uint64 & uint64 & uint64)
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_div
val u64_div (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
val u64_div (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 546, "start_col": 0, "start_line": 542 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt64.div", "FStar.Range.labeled", "Prims.l_not", "Prims.eq2", "Prims.int", "FStar.UInt64.v", "Prims.op_Division" ]
[]
false
false
false
false
false
let u64_div (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) =
UInt64.div x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_logand
val u64_logand (r: range) (x y: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> (UInt64.v x) `UInt.logand` (UInt64.v y) == UInt64.v z))
val u64_logand (r: range) (x y: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> (UInt64.v x) `UInt.logand` (UInt64.v y) == UInt64.v z))
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 21, "end_line": 562, "start_col": 0, "start_line": 558 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt64.logand", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt64.n", "FStar.UInt.logand", "FStar.UInt64.v" ]
[]
false
false
false
false
false
let u64_logand (r: range) (x y: UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> (UInt64.v x) `UInt.logand` (UInt64.v y) == UInt64.v z)) =
UInt64.logand x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint16_to_uint64
val uint16_to_uint64 (x: U16.t) : (y: U64.t{U64.v y == U16.v x})
val uint16_to_uint64 (x: U16.t) : (y: U64.t{U64.v y == U16.v x})
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 35, "end_line": 633, "start_col": 0, "start_line": 632 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt16.t -> y: FStar.UInt64.t{FStar.UInt64.v y == FStar.UInt16.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt16.t", "FStar.Int.Cast.uint16_to_uint64", "FStar.UInt64.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt64.n", "FStar.UInt16.n", "FStar.UInt64.v", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let uint16_to_uint64 (x: U16.t) : (y: U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_rem
val u64_rem (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
val u64_rem (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 554, "start_col": 0, "start_line": 550 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt64.rem", "FStar.Range.labeled", "Prims.l_not", "Prims.eq2", "Prims.int", "FStar.UInt64.v", "FStar.UInt.uint_t", "FStar.UInt64.n", "FStar.UInt.mod" ]
[]
false
false
false
false
false
let u64_rem (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) =
UInt64.rem x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint8_to_uint32
val uint8_to_uint32 (x: U8.t) : (y: U32.t{U32.v y == U8.v x})
val uint8_to_uint32 (x: U8.t) : (y: U32.t{U32.v y == U8.v x})
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 621, "start_col": 0, "start_line": 620 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt8.t -> y: FStar.UInt32.t{FStar.UInt32.v y == FStar.UInt8.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t", "FStar.Int.Cast.uint8_to_uint32", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "FStar.UInt8.n", "FStar.UInt32.v", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let uint8_to_uint32 (x: U8.t) : (y: U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.pow112
val pow112:(pow112: pos{pow112 == pow2 112})
val pow112:(pow112: pos{pow112 == pow2 112})
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 23, "start_col": 0, "start_line": 23 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow112: Prims.pos{pow112 == Prims.pow2 112}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.pos", "Prims.eq2", "Prims.pow2" ]
[]
false
false
false
false
false
let pow112:(pow112: pos{pow112 == pow2 112}) =
normalize_term (pow2 112)
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_shift_left
val u64_shift_left (r: range) (a: UInt64.t) (s: UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
val u64_shift_left (r: range) (a: UInt64.t) (s: UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 25, "end_line": 602, "start_col": 0, "start_line": 598 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> a: FStar.UInt64.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt32.t", "FStar.UInt64.shift_left", "FStar.Range.labeled", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.UInt64.n", "Prims.op_Equality", "FStar.UInt.uint_t", "FStar.UInt.shift_left", "FStar.UInt64.v" ]
[]
false
false
false
false
false
let u64_shift_left (r: range) (a: UInt64.t) (s: UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) =
UInt64.shift_left a s
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.pow168
val pow168:(pow168: pos{pow168 == pow2 168})
val pow168:(pow168: pos{pow168 == pow2 168})
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 24, "start_col": 0, "start_line": 24 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow168: Prims.pos{pow168 == Prims.pow2 168}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.pos", "Prims.eq2", "Prims.pow2" ]
[]
false
false
false
false
false
let pow168:(pow168: pos{pow168 == pow2 168}) =
normalize_term (pow2 168)
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint64_to_uint32
val uint64_to_uint32 (x: U64.t{FStar.UInt.fits (U64.v x) 32}) : (y: U32.t{U32.v y == U64.v x})
val uint64_to_uint32 (x: U64.t{FStar.UInt.fits (U64.v x) 32}) : (y: U32.t{U32.v y == U64.v x})
let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint32 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 35, "end_line": 655, "start_col": 0, "start_line": 654 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x inline_for_extraction noextract let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x (** Narrowing casts, only when narrowing does not lose any precision **) inline_for_extraction noextract let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint8 x inline_for_extraction noextract let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint16 x inline_for_extraction noextract let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint8 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt64.t{FStar.UInt.fits (FStar.UInt64.v x) 32} -> y: FStar.UInt32.t{FStar.UInt32.v y == FStar.UInt64.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t", "Prims.b2t", "FStar.UInt.fits", "FStar.UInt64.v", "FStar.Int.Cast.uint64_to_uint32", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "FStar.UInt64.n", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let uint64_to_uint32 (x: U64.t{FStar.UInt.fits (U64.v x) 32}) : (y: U32.t{U32.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint32 x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint8_to_uint64
val uint8_to_uint64 (x: U8.t) : (y: U64.t{U64.v y == U8.v x})
val uint8_to_uint64 (x: U8.t) : (y: U64.t{U64.v y == U8.v x})
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 625, "start_col": 0, "start_line": 624 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt8.t -> y: FStar.UInt64.t{FStar.UInt64.v y == FStar.UInt8.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t", "FStar.Int.Cast.uint8_to_uint64", "FStar.UInt64.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt64.n", "FStar.UInt8.n", "FStar.UInt64.v", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let uint8_to_uint64 (x: U8.t) : (y: U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.qelem_wide5
val qelem_wide5 : Type0
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 107, "end_line": 11, "start_col": 0, "start_line": 11 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple10", "Lib.IntTypes.uint64" ]
[]
false
false
false
true
true
let qelem_wide5 =
(uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_shift_right
val u64_shift_right (r: range) (a: UInt64.t) (s: UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
val u64_shift_right (r: range) (a: UInt64.t) (s: UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 26, "end_line": 594, "start_col": 0, "start_line": 590 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> a: FStar.UInt64.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt32.t", "FStar.UInt64.shift_right", "FStar.Range.labeled", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.UInt64.n", "Prims.op_Equality", "FStar.UInt.uint_t", "FStar.UInt.shift_right", "FStar.UInt64.v" ]
[]
false
false
false
false
false
let u64_shift_right (r: range) (a: UInt64.t) (s: UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) =
UInt64.shift_right a s
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint64_to_uint16
val uint64_to_uint16 (x: U64.t{FStar.UInt.fits (U64.v x) 16}) : (y: U16.t{U16.v y == U64.v x})
val uint64_to_uint16 (x: U64.t{FStar.UInt.fits (U64.v x) 16}) : (y: U16.t{U16.v y == U64.v x})
let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint16 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 35, "end_line": 659, "start_col": 0, "start_line": 658 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x inline_for_extraction noextract let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x (** Narrowing casts, only when narrowing does not lose any precision **) inline_for_extraction noextract let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint8 x inline_for_extraction noextract let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint16 x inline_for_extraction noextract let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint8 x inline_for_extraction noextract let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint32 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt64.t{FStar.UInt.fits (FStar.UInt64.v x) 16} -> y: FStar.UInt16.t{FStar.UInt16.v y == FStar.UInt64.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t", "Prims.b2t", "FStar.UInt.fits", "FStar.UInt64.v", "FStar.Int.Cast.uint64_to_uint16", "FStar.UInt16.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt16.n", "FStar.UInt64.n", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let uint64_to_uint16 (x: U64.t{FStar.UInt.fits (U64.v x) 16}) : (y: U16.t{U16.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint16 x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint16_to_uint32
val uint16_to_uint32 (x: U16.t) : (y: U32.t{U32.v y == U16.v x})
val uint16_to_uint32 (x: U16.t) : (y: U32.t{U32.v y == U16.v x})
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 35, "end_line": 629, "start_col": 0, "start_line": 628 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt16.t -> y: FStar.UInt32.t{FStar.UInt32.v y == FStar.UInt16.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt16.t", "FStar.Int.Cast.uint16_to_uint32", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "FStar.UInt16.n", "FStar.UInt32.v", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let uint16_to_uint32 (x: U16.t) : (y: U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.pow224
val pow224:(pow224: pos{pow224 == pow2 224})
val pow224:(pow224: pos{pow224 == pow2 224})
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 25, "start_col": 0, "start_line": 25 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow224: Prims.pos{pow224 == Prims.pow2 224}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.pos", "Prims.eq2", "Prims.pow2" ]
[]
false
false
false
false
false
let pow224:(pow224: pos{pow224 == pow2 224}) =
normalize_term (pow2 224)
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.cast_mul_fits_16_32
val cast_mul_fits_16_32 (x y: U16.t) : Lemma (FStar.UInt.fits ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y))) 32) [SMTPat ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))]
val cast_mul_fits_16_32 (x y: U16.t) : Lemma (FStar.UInt.fits ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y))) 32) [SMTPat ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))]
let cast_mul_fits_16_32 (x y :U16.t) : Lemma ( FStar.UInt.fits ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y))) 32) [SMTPat ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))] = let n = U32.v (C.uint16_to_uint32 x) in let m = U32.v (C.uint16_to_uint32 y) in FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 16)
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 53, "end_line": 693, "start_col": 0, "start_line": 681 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x inline_for_extraction noextract let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x (** Narrowing casts, only when narrowing does not lose any precision **) inline_for_extraction noextract let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint8 x inline_for_extraction noextract let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint16 x inline_for_extraction noextract let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint8 x inline_for_extraction noextract let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint32 x inline_for_extraction noextract let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint16 x inline_for_extraction noextract let uint64_to_uint8 (x:U64.t{FStar.UInt.fits (U64.v x) 8}) : (y:U8.t{U8.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint8 x (*** Lemma for casts ***) let cast_mul_fits_8_16 (x y :U8.t) : Lemma ( FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y))) 16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))] = let n = U16.v (C.uint8_to_uint16 x) in let m = U16.v (C.uint8_to_uint16 y) in FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 8)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt16.t -> y: FStar.UInt16.t -> FStar.Pervasives.Lemma (ensures FStar.UInt.fits (FStar.UInt32.v (FStar.Int.Cast.uint16_to_uint32 x) * FStar.UInt32.v (FStar.Int.Cast.uint16_to_uint32 y)) 32) [ SMTPat (FStar.UInt32.v (FStar.Int.Cast.uint16_to_uint32 x) * FStar.UInt32.v (FStar.Int.Cast.uint16_to_uint32 y)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.UInt16.t", "FStar.Math.Lemmas.lemma_mult_lt_sqr", "Prims.pow2", "FStar.UInt.uint_t", "FStar.UInt32.v", "FStar.Int.Cast.uint16_to_uint32", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.b2t", "FStar.UInt.fits", "Prims.op_Multiply", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.int", "Prims.Nil" ]
[]
true
false
true
false
false
let cast_mul_fits_16_32 (x y: U16.t) : Lemma (FStar.UInt.fits ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y))) 32) [SMTPat ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))] =
let n = U32.v (C.uint16_to_uint32 x) in let m = U32.v (C.uint16_to_uint32 y) in FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 16)
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint64_to_uint8
val uint64_to_uint8 (x: U64.t{FStar.UInt.fits (U64.v x) 8}) : (y: U8.t{U8.v y == U64.v x})
val uint64_to_uint8 (x: U64.t{FStar.UInt.fits (U64.v x) 8}) : (y: U8.t{U8.v y == U64.v x})
let uint64_to_uint8 (x:U64.t{FStar.UInt.fits (U64.v x) 8}) : (y:U8.t{U8.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint8 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 663, "start_col": 0, "start_line": 662 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x inline_for_extraction noextract let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x (** Narrowing casts, only when narrowing does not lose any precision **) inline_for_extraction noextract let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint8 x inline_for_extraction noextract let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint16 x inline_for_extraction noextract let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint8 x inline_for_extraction noextract let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint32 x inline_for_extraction noextract let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint16 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt64.t{FStar.UInt.fits (FStar.UInt64.v x) 8} -> y: FStar.UInt8.t{FStar.UInt8.v y == FStar.UInt64.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t", "Prims.b2t", "FStar.UInt.fits", "FStar.UInt64.v", "FStar.Int.Cast.uint64_to_uint8", "FStar.UInt8.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "FStar.UInt64.n", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let uint64_to_uint8 (x: U64.t{FStar.UInt.fits (U64.v x) 8}) : (y: U8.t{U8.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint8 x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint32_to_uint16
val uint32_to_uint16 (x: U32.t{FStar.UInt.fits (U32.v x) 16}) : (y: U16.t{U16.v y == U32.v x})
val uint32_to_uint16 (x: U32.t{FStar.UInt.fits (U32.v x) 16}) : (y: U16.t{U16.v y == U32.v x})
let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint16 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 35, "end_line": 647, "start_col": 0, "start_line": 646 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x inline_for_extraction noextract let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x (** Narrowing casts, only when narrowing does not lose any precision **) inline_for_extraction noextract let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint8 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t{FStar.UInt.fits (FStar.UInt32.v x) 16} -> y: FStar.UInt16.t{FStar.UInt16.v y == FStar.UInt32.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.b2t", "FStar.UInt.fits", "FStar.UInt32.v", "FStar.Int.Cast.uint32_to_uint16", "FStar.UInt16.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt16.n", "FStar.UInt32.n", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let uint32_to_uint16 (x: U32.t{FStar.UInt.fits (U32.v x) 16}) : (y: U16.t{U16.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint16 x
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.pow_seq
val pow_seq (#n: nat) (s: seq (natN n)) : seq int
val pow_seq (#n: nat) (s: seq (natN n)) : seq int
let pow_seq (#n:nat) (s:seq (natN n)) : seq int = init (length s) (fun (i:nat{i < length s}) -> s.[i] * pow_int n i)
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 74, "start_col": 0, "start_line": 73 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c) let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1 val add_hi (#n:nat) (a b:natN n) (c:nat1) : nat1 val reveal_add_hi (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_hi a b c == add_hi_def a b c) val reveal_add_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_hi a b c} add_hi a b c == add_hi_def a b c) let add_lo_hi (#n:pos) (a b:natN n) (c:nat1) : natN n & nat1 = (add_lo a b c, add_hi a b c) let mul_lo_def (#n:pos) (a b:natN n) : natN n = (a * b) % n val mul_lo (#n:pos) (a b:natN n) : natN n val reveal_mul_lo (#n:nat) (a b:natN n) : Lemma (mul_lo a b == mul_lo_def a b) val reveal_mul_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_lo a b} mul_lo a b == mul_lo_def a b) let mul_hi_def (#n:pos) (a b:natN n) : natN n = lemma_mul_div_n a b; (a * b) / n val mul_hi (#n:pos) (a b:natN n) : natN n val reveal_mul_hi (#n:nat) (a b:natN n) : Lemma (mul_hi a b == mul_hi_def a b) val reveal_mul_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_hi a b} mul_hi a b == mul_hi_def a b) let rec sum_seq_left (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases j) = if i = j then 0 else s.[j - 1] + sum_seq_left s i (j - 1) let rec sum_seq_right (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases (j - i)) = if i = j then 0 else s.[i] + sum_seq_right s (i + 1) j let rec pow_int (a:int) (b:nat) : int = if b = 0 then 1 else a * pow_int a (b - 1)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> FStar.Seq.Base.seq Prims.int
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Words_s.natN", "FStar.Seq.Base.init", "Prims.int", "FStar.Seq.Base.length", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Vale.Bignum.Defs.op_String_Access", "Vale.Bignum.Defs.pow_int" ]
[]
false
false
false
false
false
let pow_seq (#n: nat) (s: seq (natN n)) : seq int =
init (length s) (fun (i: nat{i < length s}) -> s.[ i ] * pow_int n i)
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.add_hi_def
val add_hi_def (#n: nat) (a b: natN n) (c: nat1) : nat1
val add_hi_def (#n: nat) (a b: natN n) (c: nat1) : nat1
let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 26, "start_col": 0, "start_line": 25 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Def.Words_s.natN n -> b: Vale.Def.Words_s.natN n -> c: Vale.Def.Words_s.nat1 -> Vale.Def.Words_s.nat1
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.nat1", "Prims.op_LessThan", "Prims.op_Addition", "Prims.bool" ]
[]
false
false
false
false
false
let add_hi_def (#n: nat) (a b: natN n) (c: nat1) : nat1 =
if a + b + c < n then 0 else 1
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.cast_mul_fits_32_64
val cast_mul_fits_32_64 (x y: U32.t) : Lemma (FStar.UInt.fits ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y))) 64) [SMTPat ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))]
val cast_mul_fits_32_64 (x y: U32.t) : Lemma (FStar.UInt.fits ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y))) 64) [SMTPat ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))]
let cast_mul_fits_32_64 (x y :U32.t) : Lemma ( FStar.UInt.fits ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y))) 64) [SMTPat ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))] = let n = U64.v (C.uint32_to_uint64 x) in let m = U64.v (C.uint32_to_uint64 y) in FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 32)
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 53, "end_line": 707, "start_col": 0, "start_line": 695 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x inline_for_extraction noextract let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x (** Narrowing casts, only when narrowing does not lose any precision **) inline_for_extraction noextract let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint8 x inline_for_extraction noextract let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint16 x inline_for_extraction noextract let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint8 x inline_for_extraction noextract let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint32 x inline_for_extraction noextract let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint16 x inline_for_extraction noextract let uint64_to_uint8 (x:U64.t{FStar.UInt.fits (U64.v x) 8}) : (y:U8.t{U8.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint8 x (*** Lemma for casts ***) let cast_mul_fits_8_16 (x y :U8.t) : Lemma ( FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y))) 16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))] = let n = U16.v (C.uint8_to_uint16 x) in let m = U16.v (C.uint8_to_uint16 y) in FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 8) let cast_mul_fits_16_32 (x y :U16.t) : Lemma ( FStar.UInt.fits ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y))) 32) [SMTPat ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))] = let n = U32.v (C.uint16_to_uint32 x) in let m = U32.v (C.uint16_to_uint32 y) in FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 16)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t -> y: FStar.UInt32.t -> FStar.Pervasives.Lemma (ensures FStar.UInt.fits (FStar.UInt64.v (FStar.Int.Cast.uint32_to_uint64 x) * FStar.UInt64.v (FStar.Int.Cast.uint32_to_uint64 y)) 64) [ SMTPat (FStar.UInt64.v (FStar.Int.Cast.uint32_to_uint64 x) * FStar.UInt64.v (FStar.Int.Cast.uint32_to_uint64 y)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.UInt32.t", "FStar.Math.Lemmas.lemma_mult_lt_sqr", "Prims.pow2", "FStar.UInt.uint_t", "FStar.UInt64.v", "FStar.Int.Cast.uint32_to_uint64", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.b2t", "FStar.UInt.fits", "Prims.op_Multiply", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.int", "Prims.Nil" ]
[]
true
false
true
false
false
let cast_mul_fits_32_64 (x y: U32.t) : Lemma (FStar.UInt.fits ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y))) 64) [SMTPat ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))] =
let n = U64.v (C.uint32_to_uint64 x) in let m = U64.v (C.uint32_to_uint64 y) in FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 32)
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.uint32_to_uint8
val uint32_to_uint8 (x: U32.t{FStar.UInt.fits (U32.v x) 8}) : (y: U8.t{U8.v y == U32.v x})
val uint32_to_uint8 (x: U32.t{FStar.UInt.fits (U32.v x) 8}) : (y: U8.t{U8.v y == U32.v x})
let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint8 x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 651, "start_col": 0, "start_line": 650 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x inline_for_extraction noextract let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x (** Narrowing casts, only when narrowing does not lose any precision **) inline_for_extraction noextract let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint8 x inline_for_extraction noextract let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint16 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t{FStar.UInt.fits (FStar.UInt32.v x) 8} -> y: FStar.UInt8.t{FStar.UInt8.v y == FStar.UInt32.v x}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.b2t", "FStar.UInt.fits", "FStar.UInt32.v", "FStar.Int.Cast.uint32_to_uint8", "FStar.UInt8.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt8.n", "FStar.UInt32.n", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let uint32_to_uint8 (x: U32.t{FStar.UInt.fits (U32.v x) 8}) : (y: U8.t{U8.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint8 x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.cast_mul_fits_8_16
val cast_mul_fits_8_16 (x y: U8.t) : Lemma (FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y))) 16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))]
val cast_mul_fits_8_16 (x y: U8.t) : Lemma (FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y))) 16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))]
let cast_mul_fits_8_16 (x y :U8.t) : Lemma ( FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y))) 16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))] = let n = U16.v (C.uint8_to_uint16 x) in let m = U16.v (C.uint8_to_uint16 y) in FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 8)
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 52, "end_line": 679, "start_col": 0, "start_line": 667 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *) inline_for_extraction noextract let id (#t: Type) (x: t) : Tot t = x (** Widening casts **) inline_for_extraction noextract let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint16 x inline_for_extraction noextract let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint32 x inline_for_extraction noextract let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) = FStar.Int.Cast.uint8_to_uint64 x inline_for_extraction noextract let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint32 x inline_for_extraction noextract let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint64 x inline_for_extraction noextract let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint64 x (** Narrowing casts, only when narrowing does not lose any precision **) inline_for_extraction noextract let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) = FStar.Int.Cast.uint16_to_uint8 x inline_for_extraction noextract let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint16 x inline_for_extraction noextract let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) = FStar.Int.Cast.uint32_to_uint8 x inline_for_extraction noextract let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint32 x inline_for_extraction noextract let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint16 x inline_for_extraction noextract let uint64_to_uint8 (x:U64.t{FStar.UInt.fits (U64.v x) 8}) : (y:U8.t{U8.v y == U64.v x}) = FStar.Int.Cast.uint64_to_uint8 x (*** Lemma for casts ***)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "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": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt8.t -> y: FStar.UInt8.t -> FStar.Pervasives.Lemma (ensures FStar.UInt.fits (FStar.UInt16.v (FStar.Int.Cast.uint8_to_uint16 x) * FStar.UInt16.v (FStar.Int.Cast.uint8_to_uint16 y)) 16) [ SMTPat (FStar.UInt16.v (FStar.Int.Cast.uint8_to_uint16 x) * FStar.UInt16.v (FStar.Int.Cast.uint8_to_uint16 y)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.UInt8.t", "FStar.Math.Lemmas.lemma_mult_lt_sqr", "Prims.pow2", "FStar.UInt.uint_t", "FStar.UInt16.v", "FStar.Int.Cast.uint8_to_uint16", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.b2t", "FStar.UInt.fits", "Prims.op_Multiply", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.int", "Prims.Nil" ]
[]
true
false
true
false
false
let cast_mul_fits_8_16 (x y: U8.t) : Lemma (FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y))) 16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))] =
let n = U16.v (C.uint8_to_uint16 x) in let m = U16.v (C.uint8_to_uint16 y) in FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 8)
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.pow280
val pow280:(pow280: pos{pow280 == pow2 280})
val pow280:(pow280: pos{pow280 == pow2 280})
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 26, "start_col": 0, "start_line": 26 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow280: Prims.pos{pow280 == Prims.pow2 280}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.pos", "Prims.eq2", "Prims.pow2" ]
[]
false
false
false
false
false
let pow280:(pow280: pos{pow280 == pow2 280}) =
normalize_term (pow2 280)
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.add_lo_hi
val add_lo_hi (#n: pos) (a b: natN n) (c: nat1) : natN n & nat1
val add_lo_hi (#n: pos) (a b: natN n) (c: nat1) : natN n & nat1
let add_lo_hi (#n:pos) (a b:natN n) (c:nat1) : natN n & nat1 = (add_lo a b c, add_hi a b c)
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 34, "start_col": 0, "start_line": 33 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c) let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1 val add_hi (#n:nat) (a b:natN n) (c:nat1) : nat1 val reveal_add_hi (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_hi a b c == add_hi_def a b c) val reveal_add_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_hi a b c} add_hi a b c == add_hi_def a b c)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Def.Words_s.natN n -> b: Vale.Def.Words_s.natN n -> c: Vale.Def.Words_s.nat1 -> Vale.Def.Words_s.natN n * Vale.Def.Words_s.nat1
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.nat1", "FStar.Pervasives.Native.Mktuple2", "Vale.Bignum.Defs.add_lo", "Vale.Bignum.Defs.add_hi", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
false
false
let add_lo_hi (#n: pos) (a b: natN n) (c: nat1) : natN n & nat1 =
(add_lo a b c, add_hi a b c)
false
Lib.IntTypes.Compatibility.fst
Lib.IntTypes.Compatibility.inttype
val inttype : Type0
let inttype = t:inttype{unsigned t}
{ "file_name": "lib/Lib.IntTypes.Compatibility.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 12, "start_col": 0, "start_line": 12 }
module Lib.IntTypes.Compatibility open Lib.IntTypes val uint_v_size_lemma: s:size_nat -> Lemma (ensures (uint_v (size s) == s)) [SMTPat (uint_v (size s))] let uint_v_size_lemma s = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Lib.IntTypes.Compatibility.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.inttype", "Prims.b2t", "Lib.IntTypes.unsigned" ]
[]
false
false
false
true
true
let inttype =
t: inttype{unsigned t}
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.add_lo_def
val add_lo_def (#n: nat) (a b: natN n) (c: nat1) : natN n
val add_lo_def (#n: nat) (a b: natN n) (c: nat1) : natN n
let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 18, "start_col": 0, "start_line": 16 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Def.Words_s.natN n -> b: Vale.Def.Words_s.natN n -> c: Vale.Def.Words_s.nat1 -> Vale.Def.Words_s.natN n
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.nat1", "Prims.op_LessThan", "Prims.bool", "Prims.op_Subtraction", "Prims.int", "Prims.op_Addition" ]
[]
false
false
false
false
false
let add_lo_def (#n: nat) (a b: natN n) (c: nat1) : natN n =
let x = a + b + c in if x < n then x else x - n
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.pow56
val pow56:(pow56: pos{pow2 64 == 256 * pow56 /\ pow56 == pow2 56})
val pow56:(pow56: pos{pow2 64 == 256 * pow56 /\ pow56 == pow2 56})
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 20, "start_col": 0, "start_line": 14 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow56: Prims.pos{Prims.pow2 64 == 256 * pow56 /\ pow56 == Prims.pow2 56}
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.pow2", "FStar.Mul.op_Star", "Prims.pos", "Prims.b2t", "Prims.op_GreaterThan", "FStar.Pervasives.normalize_term" ]
[]
false
false
false
false
false
let pow56:(pow56: pos{pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56:pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == (65536 * pow56) * pow56); pow56
false
Lib.IntTypes.Compatibility.fst
Lib.IntTypes.Compatibility.zeroes
val zeroes : t: Lib.IntTypes.inttype -> l: Lib.IntTypes.secrecy_level -> n: Lib.IntTypes.int_t t l {Lib.IntTypes.v n = 0}
let zeroes t l = zeros t l
{ "file_name": "lib/Lib.IntTypes.Compatibility.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 26, "start_col": 0, "start_line": 26 }
module Lib.IntTypes.Compatibility open Lib.IntTypes val uint_v_size_lemma: s:size_nat -> Lemma (ensures (uint_v (size s) == s)) [SMTPat (uint_v (size s))] let uint_v_size_lemma s = () unfold let inttype = t:inttype{unsigned t} val uintv_extensionality: #t:inttype -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> Lemma (requires uint_v a == uint_v b) (ensures a == b) let uintv_extensionality #t #l a b = () let nat_to_uint (#t:inttype) (#l:secrecy_level) (n:nat{n <= maxint t}) : u:uint_t t l{uint_v u == n} = uint #t #l n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Lib.IntTypes.Compatibility.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Lib.IntTypes.inttype -> l: Lib.IntTypes.secrecy_level -> n: Lib.IntTypes.int_t t l {Lib.IntTypes.v n = 0}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.inttype", "Lib.IntTypes.secrecy_level", "Lib.IntTypes.zeros", "Lib.IntTypes.int_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Lib.IntTypes.v" ]
[]
false
false
false
false
false
let zeroes t l =
zeros t l
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.sum_pow_seq
val sum_pow_seq (#n: nat) (s: seq (natN n)) : int
val sum_pow_seq (#n: nat) (s: seq (natN n)) : int
let sum_pow_seq (#n:nat) (s:seq (natN n)) : int = sum_pow_seq_left s (length s)
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 80, "start_col": 0, "start_line": 79 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c) let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1 val add_hi (#n:nat) (a b:natN n) (c:nat1) : nat1 val reveal_add_hi (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_hi a b c == add_hi_def a b c) val reveal_add_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_hi a b c} add_hi a b c == add_hi_def a b c) let add_lo_hi (#n:pos) (a b:natN n) (c:nat1) : natN n & nat1 = (add_lo a b c, add_hi a b c) let mul_lo_def (#n:pos) (a b:natN n) : natN n = (a * b) % n val mul_lo (#n:pos) (a b:natN n) : natN n val reveal_mul_lo (#n:nat) (a b:natN n) : Lemma (mul_lo a b == mul_lo_def a b) val reveal_mul_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_lo a b} mul_lo a b == mul_lo_def a b) let mul_hi_def (#n:pos) (a b:natN n) : natN n = lemma_mul_div_n a b; (a * b) / n val mul_hi (#n:pos) (a b:natN n) : natN n val reveal_mul_hi (#n:nat) (a b:natN n) : Lemma (mul_hi a b == mul_hi_def a b) val reveal_mul_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_hi a b} mul_hi a b == mul_hi_def a b) let rec sum_seq_left (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases j) = if i = j then 0 else s.[j - 1] + sum_seq_left s i (j - 1) let rec sum_seq_right (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases (j - i)) = if i = j then 0 else s.[i] + sum_seq_right s (i + 1) j let rec pow_int (a:int) (b:nat) : int = if b = 0 then 1 else a * pow_int a (b - 1) let pow_seq (#n:nat) (s:seq (natN n)) : seq int = init (length s) (fun (i:nat{i < length s}) -> s.[i] * pow_int n i) let sum_pow_seq_left (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : int = sum_seq_left (pow_seq s) 0 i
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Words_s.natN", "Vale.Bignum.Defs.sum_pow_seq_left", "FStar.Seq.Base.length", "Prims.int" ]
[]
false
false
false
false
false
let sum_pow_seq (#n: nat) (s: seq (natN n)) : int =
sum_pow_seq_left s (length s)
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.mul_hi_def
val mul_hi_def (#n: pos) (a b: natN n) : natN n
val mul_hi_def (#n: pos) (a b: natN n) : natN n
let mul_hi_def (#n:pos) (a b:natN n) : natN n = lemma_mul_div_n a b; (a * b) / n
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 46, "start_col": 0, "start_line": 44 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c) let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1 val add_hi (#n:nat) (a b:natN n) (c:nat1) : nat1 val reveal_add_hi (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_hi a b c == add_hi_def a b c) val reveal_add_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_hi a b c} add_hi a b c == add_hi_def a b c) let add_lo_hi (#n:pos) (a b:natN n) (c:nat1) : natN n & nat1 = (add_lo a b c, add_hi a b c) let mul_lo_def (#n:pos) (a b:natN n) : natN n = (a * b) % n val mul_lo (#n:pos) (a b:natN n) : natN n val reveal_mul_lo (#n:nat) (a b:natN n) : Lemma (mul_lo a b == mul_lo_def a b) val reveal_mul_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_lo a b} mul_lo a b == mul_lo_def a b)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Def.Words_s.natN n -> b: Vale.Def.Words_s.natN n -> Vale.Def.Words_s.natN n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Vale.Def.Words_s.natN", "Prims.op_Division", "FStar.Mul.op_Star", "Prims.unit", "Vale.Bignum.Defs.lemma_mul_div_n" ]
[]
false
false
false
false
false
let mul_hi_def (#n: pos) (a b: natN n) : natN n =
lemma_mul_div_n a b; (a * b) / n
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.pow_int
val pow_int (a: int) (b: nat) : int
val pow_int (a: int) (b: nat) : int
let rec pow_int (a:int) (b:nat) : int = if b = 0 then 1 else a * pow_int a (b - 1)
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 71, "start_col": 0, "start_line": 69 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c) let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1 val add_hi (#n:nat) (a b:natN n) (c:nat1) : nat1 val reveal_add_hi (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_hi a b c == add_hi_def a b c) val reveal_add_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_hi a b c} add_hi a b c == add_hi_def a b c) let add_lo_hi (#n:pos) (a b:natN n) (c:nat1) : natN n & nat1 = (add_lo a b c, add_hi a b c) let mul_lo_def (#n:pos) (a b:natN n) : natN n = (a * b) % n val mul_lo (#n:pos) (a b:natN n) : natN n val reveal_mul_lo (#n:nat) (a b:natN n) : Lemma (mul_lo a b == mul_lo_def a b) val reveal_mul_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_lo a b} mul_lo a b == mul_lo_def a b) let mul_hi_def (#n:pos) (a b:natN n) : natN n = lemma_mul_div_n a b; (a * b) / n val mul_hi (#n:pos) (a b:natN n) : natN n val reveal_mul_hi (#n:nat) (a b:natN n) : Lemma (mul_hi a b == mul_hi_def a b) val reveal_mul_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_hi a b} mul_hi a b == mul_hi_def a b) let rec sum_seq_left (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases j) = if i = j then 0 else s.[j - 1] + sum_seq_left s i (j - 1) let rec sum_seq_right (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases (j - i)) = if i = j then 0 else s.[i] + sum_seq_right s (i + 1) j
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Prims.int -> b: Prims.nat -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.nat", "Prims.op_Equality", "Prims.bool", "FStar.Mul.op_Star", "Vale.Bignum.Defs.pow_int", "Prims.op_Subtraction" ]
[ "recursion" ]
false
false
false
true
false
let rec pow_int (a: int) (b: nat) : int =
if b = 0 then 1 else a * pow_int a (b - 1)
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.sum_seq_right
val sum_seq_right (s: seq int) (i j: nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases (j - i))
val sum_seq_right (s: seq int) (i j: nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases (j - i))
let rec sum_seq_right (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases (j - i)) = if i = j then 0 else s.[i] + sum_seq_right s (i + 1) j
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 67, "start_col": 0, "start_line": 61 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c) let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1 val add_hi (#n:nat) (a b:natN n) (c:nat1) : nat1 val reveal_add_hi (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_hi a b c == add_hi_def a b c) val reveal_add_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_hi a b c} add_hi a b c == add_hi_def a b c) let add_lo_hi (#n:pos) (a b:natN n) (c:nat1) : natN n & nat1 = (add_lo a b c, add_hi a b c) let mul_lo_def (#n:pos) (a b:natN n) : natN n = (a * b) % n val mul_lo (#n:pos) (a b:natN n) : natN n val reveal_mul_lo (#n:nat) (a b:natN n) : Lemma (mul_lo a b == mul_lo_def a b) val reveal_mul_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_lo a b} mul_lo a b == mul_lo_def a b) let mul_hi_def (#n:pos) (a b:natN n) : natN n = lemma_mul_div_n a b; (a * b) / n val mul_hi (#n:pos) (a b:natN n) : natN n val reveal_mul_hi (#n:nat) (a b:natN n) : Lemma (mul_hi a b == mul_hi_def a b) val reveal_mul_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_hi a b} mul_hi a b == mul_hi_def a b) let rec sum_seq_left (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases j) = if i = j then 0 else s.[j - 1] + sum_seq_left s i (j - 1)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq Prims.int -> i: Prims.nat -> j: Prims.nat -> Prims.Pure Prims.int
Prims.Pure
[ "" ]
[]
[ "FStar.Seq.Base.seq", "Prims.int", "Prims.nat", "Prims.op_Equality", "Prims.bool", "Prims.op_Addition", "Vale.Bignum.Defs.op_String_Access", "Vale.Bignum.Defs.sum_seq_right", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.l_True" ]
[ "recursion" ]
false
false
false
false
false
let rec sum_seq_right (s: seq int) (i j: nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases (j - i)) =
if i = j then 0 else s.[ i ] + sum_seq_right s (i + 1) j
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.sum_seq_left
val sum_seq_left (s: seq int) (i j: nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases j)
val sum_seq_left (s: seq int) (i j: nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases j)
let rec sum_seq_left (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases j) = if i = j then 0 else s.[j - 1] + sum_seq_left s i (j - 1)
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 59, "start_col": 0, "start_line": 53 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c) let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1 val add_hi (#n:nat) (a b:natN n) (c:nat1) : nat1 val reveal_add_hi (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_hi a b c == add_hi_def a b c) val reveal_add_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_hi a b c} add_hi a b c == add_hi_def a b c) let add_lo_hi (#n:pos) (a b:natN n) (c:nat1) : natN n & nat1 = (add_lo a b c, add_hi a b c) let mul_lo_def (#n:pos) (a b:natN n) : natN n = (a * b) % n val mul_lo (#n:pos) (a b:natN n) : natN n val reveal_mul_lo (#n:nat) (a b:natN n) : Lemma (mul_lo a b == mul_lo_def a b) val reveal_mul_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_lo a b} mul_lo a b == mul_lo_def a b) let mul_hi_def (#n:pos) (a b:natN n) : natN n = lemma_mul_div_n a b; (a * b) / n val mul_hi (#n:pos) (a b:natN n) : natN n val reveal_mul_hi (#n:nat) (a b:natN n) : Lemma (mul_hi a b == mul_hi_def a b) val reveal_mul_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_hi a b} mul_hi a b == mul_hi_def a b)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq Prims.int -> i: Prims.nat -> j: Prims.nat -> Prims.Pure Prims.int
Prims.Pure
[ "" ]
[]
[ "FStar.Seq.Base.seq", "Prims.int", "Prims.nat", "Prims.op_Equality", "Prims.bool", "Prims.op_Addition", "Vale.Bignum.Defs.op_String_Access", "Prims.op_Subtraction", "Vale.Bignum.Defs.sum_seq_left", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.l_True" ]
[ "recursion" ]
false
false
false
false
false
let rec sum_seq_left (s: seq int) (i j: nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases j) =
if i = j then 0 else s.[ j - 1 ] + sum_seq_left s i (j - 1)
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.sum_pow_seq_left
val sum_pow_seq_left (#n: nat) (s: seq (natN n)) (i: nat{i <= length s}) : int
val sum_pow_seq_left (#n: nat) (s: seq (natN n)) (i: nat{i <= length s}) : int
let sum_pow_seq_left (#n:nat) (s:seq (natN n)) (i:nat{i <= length s}) : int = sum_seq_left (pow_seq s) 0 i
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 77, "start_col": 0, "start_line": 76 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c) let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1 val add_hi (#n:nat) (a b:natN n) (c:nat1) : nat1 val reveal_add_hi (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_hi a b c == add_hi_def a b c) val reveal_add_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_hi a b c} add_hi a b c == add_hi_def a b c) let add_lo_hi (#n:pos) (a b:natN n) (c:nat1) : natN n & nat1 = (add_lo a b c, add_hi a b c) let mul_lo_def (#n:pos) (a b:natN n) : natN n = (a * b) % n val mul_lo (#n:pos) (a b:natN n) : natN n val reveal_mul_lo (#n:nat) (a b:natN n) : Lemma (mul_lo a b == mul_lo_def a b) val reveal_mul_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_lo a b} mul_lo a b == mul_lo_def a b) let mul_hi_def (#n:pos) (a b:natN n) : natN n = lemma_mul_div_n a b; (a * b) / n val mul_hi (#n:pos) (a b:natN n) : natN n val reveal_mul_hi (#n:nat) (a b:natN n) : Lemma (mul_hi a b == mul_hi_def a b) val reveal_mul_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n).{:pattern mul_hi a b} mul_hi a b == mul_hi_def a b) let rec sum_seq_left (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases j) = if i = j then 0 else s.[j - 1] + sum_seq_left s i (j - 1) let rec sum_seq_right (s:seq int) (i j:nat) : Pure int (requires i <= j /\ j <= length s) (ensures fun _ -> True) (decreases (j - i)) = if i = j then 0 else s.[i] + sum_seq_right s (i + 1) j let rec pow_int (a:int) (b:nat) : int = if b = 0 then 1 else a * pow_int a (b - 1) let pow_seq (#n:nat) (s:seq (natN n)) : seq int = init (length s) (fun (i:nat{i < length s}) -> s.[i] * pow_int n i)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq (Vale.Def.Words_s.natN n) -> i: Prims.nat{i <= FStar.Seq.Base.length s} -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Words_s.natN", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Vale.Bignum.Defs.sum_seq_left", "Vale.Bignum.Defs.pow_seq", "Prims.int" ]
[]
false
false
false
false
false
let sum_pow_seq_left (#n: nat) (s: seq (natN n)) (i: nat{i <= length s}) : int =
sum_seq_left (pow_seq s) 0 i
false
Vale.Bignum.Defs.fsti
Vale.Bignum.Defs.mul_lo_def
val mul_lo_def (#n: pos) (a b: natN n) : natN n
val mul_lo_def (#n: pos) (a b: natN n) : natN n
let mul_lo_def (#n:pos) (a b:natN n) : natN n = (a * b) % n
{ "file_name": "vale/code/crypto/bignum/Vale.Bignum.Defs.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 37, "start_col": 0, "start_line": 36 }
module Vale.Bignum.Defs open FStar.Mul open FStar.Seq open Vale.Def.Words_s unfold let (.[]) = Seq.index val lemma_mul_nat_bound (a a' b b':nat) : Lemma (requires a <= a' /\ b <= b') (ensures 0 <= a * b /\ a * b <= a' * b') val lemma_mul_n_bound (#n:nat) (a b:natN n) : Lemma (0 <= a * b /\ a * b <= (n - 1) * (n - 1)) val lemma_mul_div_n_lt (#n:nat) (a b:natN n) : Lemma ((a * b) / n < (if n <= 1 then n else n - 1)) val lemma_mul_div_n (#n:pos) (a b:natN n) : Lemma (0 <= (a * b) / n /\ (a * b) / n < n) let add_lo_def (#n:nat) (a b:natN n) (c:nat1) : natN n = let x = a + b + c in if x < n then x else x - n val add_lo (#n:nat) (a b:natN n) (c:nat1) : natN n val reveal_add_lo (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_lo a b c == add_lo_def a b c) val reveal_add_lo_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_lo a b c} add_lo a b c == add_lo_def a b c) let add_hi_def (#n:nat) (a b:natN n) (c:nat1) : nat1 = if a + b + c < n then 0 else 1 val add_hi (#n:nat) (a b:natN n) (c:nat1) : nat1 val reveal_add_hi (#n:nat) (a b:natN n) (c:nat1) : Lemma (add_hi a b c == add_hi_def a b c) val reveal_add_hi_all (_:unit) : Lemma (forall (n:nat) (a b:natN n) (c:nat1).{:pattern add_hi a b c} add_hi a b c == add_hi_def a b c) let add_lo_hi (#n:pos) (a b:natN n) (c:nat1) : natN n & nat1 = (add_lo a b c, add_hi a b c)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Bignum.Defs.fsti" }
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Vale.Def.Words_s.natN n -> b: Vale.Def.Words_s.natN n -> Vale.Def.Words_s.natN n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Vale.Def.Words_s.natN", "Prims.op_Modulus", "FStar.Mul.op_Star" ]
[]
false
false
false
false
false
let mul_lo_def (#n: pos) (a b: natN n) : natN n =
(a * b) % n
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_mul_u64
val bn_mul_u64:bn_mul_st U64
val bn_mul_u64:bn_mul_st U64
let bn_mul_u64 : bn_mul_st U64 = bn_mul
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 159, "start_col": 0, "start_line": 159 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j) inline_for_extraction noextract let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) inline_for_extraction noextract val bn_mul: #t:limb_t -> bn_mul_st t let bn_mul #t aLen a bLen b res = [@inline_let] let resLen = aLen +! bLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@ inline_let] let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in loop1 h0 bLen res spec (fun j -> Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j); let bj = b.(j) in res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res ) [@CInline] let bn_mul_u32 : bn_mul_st U32 = bn_mul
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Multiplication.bn_mul_st Lib.IntTypes.U64
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Multiplication.bn_mul", "Lib.IntTypes.U64" ]
[]
false
false
false
true
false
let bn_mul_u64:bn_mul_st U64 =
bn_mul
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_mul_u32
val bn_mul_u32:bn_mul_st U32
val bn_mul_u32:bn_mul_st U32
let bn_mul_u32 : bn_mul_st U32 = bn_mul
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 157, "start_col": 0, "start_line": 157 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j) inline_for_extraction noextract let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) inline_for_extraction noextract val bn_mul: #t:limb_t -> bn_mul_st t let bn_mul #t aLen a bLen b res = [@inline_let] let resLen = aLen +! bLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@ inline_let] let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in loop1 h0 bLen res spec (fun j -> Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j); let bj = b.(j) in res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Multiplication.bn_mul_st Lib.IntTypes.U32
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Multiplication.bn_mul", "Lib.IntTypes.U32" ]
[]
false
false
false
true
false
let bn_mul_u32:bn_mul_st U32 =
bn_mul
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.pow392
val pow392:(pow392: pos{pow392 == pow2 392})
val pow392:(pow392: pos{pow392 == pow2 392})
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 28, "start_col": 0, "start_line": 28 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow392: Prims.pos{pow392 == Prims.pow2 392}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.pos", "Prims.eq2", "Prims.pow2" ]
[]
false
false
false
false
false
let pow392:(pow392: pos{pow392 == pow2 392}) =
normalize_term (pow2 392)
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_sqr_u64
val bn_sqr_u64:bn_sqr_st U64
val bn_sqr_u64:bn_sqr_st U64
let bn_sqr_u64 : bn_sqr_st U64 = bn_sqr
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 239, "start_col": 0, "start_line": 239 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j) inline_for_extraction noextract let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) inline_for_extraction noextract val bn_mul: #t:limb_t -> bn_mul_st t let bn_mul #t aLen a bLen b res = [@inline_let] let resLen = aLen +! bLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@ inline_let] let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in loop1 h0 bLen res spec (fun j -> Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j); let bj = b.(j) in res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res ) [@CInline] let bn_mul_u32 : bn_mul_st U32 = bn_mul [@CInline] let bn_mul_u64 : bn_mul_st U64 = bn_mul inline_for_extraction noextract let bn_mul_u (#t:limb_t) : bn_mul_st t = match t with | U32 -> bn_mul_u32 | U64 -> bn_mul_u64 inline_for_extraction noextract val bn_sqr_diag: #t:limb_t -> aLen:size_t{v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a /\ as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a)) let bn_sqr_diag #t aLen a res = let h0 = ST.get () in [@inline_let] let spec h = SS.bn_sqr_diag_f (as_seq h a) in loop1 h0 aLen res spec (fun i -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i); let (hi, lo) = mul_wide a.(i) a.(i) in res.(2ul *! i) <- lo; res.(2ul *! i +! 1ul) <- hi) // This code is taken from BoringSSL // https://github.com/google/boringssl/blob/master/crypto/fipsmodule/bn/mul.c#L551 inline_for_extraction noextract let bn_sqr_st (t:limb_t) = aLen:size_t{0 < v aLen /\ v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr (as_seq h0 a)) inline_for_extraction noextract val bn_sqr: #t:limb_t -> bn_sqr_st t let bn_sqr #t aLen a res = push_frame (); [@inline_let] let resLen = aLen +! aLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@inline_let] let spec h = SS.bn_sqr_f (as_seq h a) in loop1 h0 aLen res spec (fun j -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v j); let ab = sub a 0ul j in let a_j = a.(j) in res.(j +! j) <- bn_mul1_lshift_add j ab a_j resLen j res ); let c0 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res res res in LowStar.Ignore.ignore c0; let tmp = create resLen (uint #t 0) in bn_sqr_diag aLen a tmp; let c1 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res tmp res in LowStar.Ignore.ignore c1; pop_frame () [@CInline] let bn_sqr_u32 : bn_sqr_st U32 = bn_sqr
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Multiplication.bn_sqr_st Lib.IntTypes.U64
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Multiplication.bn_sqr", "Lib.IntTypes.U64" ]
[]
false
false
false
true
false
let bn_sqr_u64:bn_sqr_st U64 =
bn_sqr
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.pow336
val pow336:(pow336: pos{pow336 == pow2 336})
val pow336:(pow336: pos{pow336 == pow2 336})
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 27, "start_col": 0, "start_line": 27 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow336: Prims.pos{pow336 == Prims.pow2 336}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.pos", "Prims.eq2", "Prims.pow2" ]
[]
false
false
false
false
false
let pow336:(pow336: pos{pow336 == pow2 336}) =
normalize_term (pow2 336)
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_sqr_u32
val bn_sqr_u32:bn_sqr_st U32
val bn_sqr_u32:bn_sqr_st U32
let bn_sqr_u32 : bn_sqr_st U32 = bn_sqr
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 237, "start_col": 0, "start_line": 237 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j) inline_for_extraction noextract let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) inline_for_extraction noextract val bn_mul: #t:limb_t -> bn_mul_st t let bn_mul #t aLen a bLen b res = [@inline_let] let resLen = aLen +! bLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@ inline_let] let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in loop1 h0 bLen res spec (fun j -> Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j); let bj = b.(j) in res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res ) [@CInline] let bn_mul_u32 : bn_mul_st U32 = bn_mul [@CInline] let bn_mul_u64 : bn_mul_st U64 = bn_mul inline_for_extraction noextract let bn_mul_u (#t:limb_t) : bn_mul_st t = match t with | U32 -> bn_mul_u32 | U64 -> bn_mul_u64 inline_for_extraction noextract val bn_sqr_diag: #t:limb_t -> aLen:size_t{v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a /\ as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a)) let bn_sqr_diag #t aLen a res = let h0 = ST.get () in [@inline_let] let spec h = SS.bn_sqr_diag_f (as_seq h a) in loop1 h0 aLen res spec (fun i -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i); let (hi, lo) = mul_wide a.(i) a.(i) in res.(2ul *! i) <- lo; res.(2ul *! i +! 1ul) <- hi) // This code is taken from BoringSSL // https://github.com/google/boringssl/blob/master/crypto/fipsmodule/bn/mul.c#L551 inline_for_extraction noextract let bn_sqr_st (t:limb_t) = aLen:size_t{0 < v aLen /\ v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr (as_seq h0 a)) inline_for_extraction noextract val bn_sqr: #t:limb_t -> bn_sqr_st t let bn_sqr #t aLen a res = push_frame (); [@inline_let] let resLen = aLen +! aLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@inline_let] let spec h = SS.bn_sqr_f (as_seq h a) in loop1 h0 aLen res spec (fun j -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v j); let ab = sub a 0ul j in let a_j = a.(j) in res.(j +! j) <- bn_mul1_lshift_add j ab a_j resLen j res ); let c0 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res res res in LowStar.Ignore.ignore c0; let tmp = create resLen (uint #t 0) in bn_sqr_diag aLen a tmp; let c1 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res tmp res in LowStar.Ignore.ignore c1; pop_frame ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Multiplication.bn_sqr_st Lib.IntTypes.U32
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Multiplication.bn_sqr", "Lib.IntTypes.U32" ]
[]
false
false
false
true
false
let bn_sqr_u32:bn_sqr_st U32 =
bn_sqr
false
Lib.IntTypes.Compatibility.fst
Lib.IntTypes.Compatibility.nat_to_uint
val nat_to_uint (#t: inttype) (#l: secrecy_level) (n: nat{n <= maxint t}) : u: uint_t t l {uint_v u == n}
val nat_to_uint (#t: inttype) (#l: secrecy_level) (n: nat{n <= maxint t}) : u: uint_t t l {uint_v u == n}
let nat_to_uint (#t:inttype) (#l:secrecy_level) (n:nat{n <= maxint t}) : u:uint_t t l{uint_v u == n} = uint #t #l n
{ "file_name": "lib/Lib.IntTypes.Compatibility.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 115, "end_line": 24, "start_col": 0, "start_line": 24 }
module Lib.IntTypes.Compatibility open Lib.IntTypes val uint_v_size_lemma: s:size_nat -> Lemma (ensures (uint_v (size s) == s)) [SMTPat (uint_v (size s))] let uint_v_size_lemma s = () unfold let inttype = t:inttype{unsigned t} val uintv_extensionality: #t:inttype -> #l:secrecy_level -> a:uint_t t l -> b:uint_t t l -> Lemma (requires uint_v a == uint_v b) (ensures a == b) let uintv_extensionality #t #l a b = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Lib.IntTypes.Compatibility.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat{n <= Lib.IntTypes.maxint t} -> u29: Lib.IntTypes.uint_t t l {Lib.IntTypes.uint_v u29 == n}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.Compatibility.inttype", "Lib.IntTypes.secrecy_level", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.maxint", "Lib.IntTypes.uint", "Lib.IntTypes.uint_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.uint_v" ]
[]
false
false
false
false
false
let nat_to_uint (#t: inttype) (#l: secrecy_level) (n: nat{n <= maxint t}) : u: uint_t t l {uint_v u == n} =
uint #t #l n
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.pow448
val pow448:(pow448: pos{pow448 == pow2 448})
val pow448:(pow448: pos{pow448 == pow2 448})
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 29, "start_col": 0, "start_line": 29 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow448: Prims.pos{pow448 == Prims.pow2 448}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.pos", "Prims.eq2", "Prims.pow2" ]
[]
false
false
false
false
false
let pow448:(pow448: pos{pow448 == pow2 448}) =
normalize_term (pow2 448)
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.max56
val max56 : Prims.int
let max56 = pow56 - 1
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 46, "start_col": 0, "start_line": 46 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) let scale64 = s:nat{s <= 256} let nat5 = (nat & nat & nat & nat & nat) let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256} let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\ x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256}
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.int
Prims.Tot
[ "total" ]
[]
[ "Prims.op_Subtraction", "Hacl.Spec.BignumQ.Definitions.pow56" ]
[]
false
false
false
true
false
let max56 =
pow56 - 1
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.pow504
val pow504:(pow504: pos{pow504 == pow2 504})
val pow504:(pow504: pos{pow504 == pow2 504})
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 30, "start_col": 0, "start_line": 30 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pow504: Prims.pos{pow504 == Prims.pow2 504}
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.pos", "Prims.eq2", "Prims.pow2" ]
[]
false
false
false
false
false
let pow504:(pow504: pos{pow504 == pow2 504}) =
normalize_term (pow2 504)
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test1_hash
val test1_hash : Spec.Hash.Definitions.hash_alg
let test1_hash = Spec.Hash.Definitions.SHA2_256
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 17, "start_col": 0, "start_line": 17 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Spec.Hash.Definitions.hash_alg
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.SHA2_256" ]
[]
false
false
false
true
false
let test1_hash =
Spec.Hash.Definitions.SHA2_256
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test1_len
val test1_len : Prims.int
let test1_len = 42
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 46, "start_col": 0, "start_line": 46 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.int
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let test1_len =
42
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.nat5
val nat5 : Type0
let nat5 = (nat & nat & nat & nat & nat)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 34, "start_col": 0, "start_line": 34 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple5", "Prims.nat" ]
[]
false
false
false
true
true
let nat5 =
(nat & nat & nat & nat & nat)
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test2_hash
val test2_hash : Spec.Hash.Definitions.hash_alg
let test2_hash = Spec.Hash.Definitions.SHA2_256
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 74, "start_col": 0, "start_line": 74 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Spec.Hash.Definitions.hash_alg
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.SHA2_256" ]
[]
false
false
false
true
false
let test2_hash =
Spec.Hash.Definitions.SHA2_256
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_sqr_u
val bn_sqr_u (#t: limb_t) : bn_sqr_st t
val bn_sqr_u (#t: limb_t) : bn_sqr_st t
let bn_sqr_u (#t:limb_t) : bn_sqr_st t = match t with | U32 -> bn_sqr_u32 | U64 -> bn_sqr_u64
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 245, "start_col": 0, "start_line": 242 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j) inline_for_extraction noextract let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) inline_for_extraction noextract val bn_mul: #t:limb_t -> bn_mul_st t let bn_mul #t aLen a bLen b res = [@inline_let] let resLen = aLen +! bLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@ inline_let] let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in loop1 h0 bLen res spec (fun j -> Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j); let bj = b.(j) in res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res ) [@CInline] let bn_mul_u32 : bn_mul_st U32 = bn_mul [@CInline] let bn_mul_u64 : bn_mul_st U64 = bn_mul inline_for_extraction noextract let bn_mul_u (#t:limb_t) : bn_mul_st t = match t with | U32 -> bn_mul_u32 | U64 -> bn_mul_u64 inline_for_extraction noextract val bn_sqr_diag: #t:limb_t -> aLen:size_t{v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a /\ as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a)) let bn_sqr_diag #t aLen a res = let h0 = ST.get () in [@inline_let] let spec h = SS.bn_sqr_diag_f (as_seq h a) in loop1 h0 aLen res spec (fun i -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i); let (hi, lo) = mul_wide a.(i) a.(i) in res.(2ul *! i) <- lo; res.(2ul *! i +! 1ul) <- hi) // This code is taken from BoringSSL // https://github.com/google/boringssl/blob/master/crypto/fipsmodule/bn/mul.c#L551 inline_for_extraction noextract let bn_sqr_st (t:limb_t) = aLen:size_t{0 < v aLen /\ v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr (as_seq h0 a)) inline_for_extraction noextract val bn_sqr: #t:limb_t -> bn_sqr_st t let bn_sqr #t aLen a res = push_frame (); [@inline_let] let resLen = aLen +! aLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@inline_let] let spec h = SS.bn_sqr_f (as_seq h a) in loop1 h0 aLen res spec (fun j -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v j); let ab = sub a 0ul j in let a_j = a.(j) in res.(j +! j) <- bn_mul1_lshift_add j ab a_j resLen j res ); let c0 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res res res in LowStar.Ignore.ignore c0; let tmp = create resLen (uint #t 0) in bn_sqr_diag aLen a tmp; let c1 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res tmp res in LowStar.Ignore.ignore c1; pop_frame () [@CInline] let bn_sqr_u32 : bn_sqr_st U32 = bn_sqr [@CInline] let bn_sqr_u64 : bn_sqr_st U64 = bn_sqr
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Multiplication.bn_sqr_st t
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Multiplication.bn_sqr_u32", "Hacl.Bignum.Multiplication.bn_sqr_u64", "Hacl.Bignum.Multiplication.bn_sqr_st" ]
[]
false
false
false
false
false
let bn_sqr_u (#t: limb_t) : bn_sqr_st t =
match t with | U32 -> bn_sqr_u32 | U64 -> bn_sqr_u64
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test3_hash
val test3_hash : Spec.Hash.Definitions.hash_alg
let test3_hash = Spec.Hash.Definitions.SHA2_256
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 159, "start_col": 0, "start_line": 159 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2 let test2_hash = Spec.Hash.Definitions.SHA2_256 let test2_ikm : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_salt : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x60uy; 0x61uy; 0x62uy; 0x63uy; 0x64uy; 0x65uy; 0x66uy; 0x67uy; 0x68uy; 0x69uy; 0x6auy; 0x6buy; 0x6cuy; 0x6duy; 0x6euy; 0x6fuy; 0x70uy; 0x71uy; 0x72uy; 0x73uy; 0x74uy; 0x75uy; 0x76uy; 0x77uy; 0x78uy; 0x79uy; 0x7auy; 0x7buy; 0x7cuy; 0x7duy; 0x7euy; 0x7fuy; 0x80uy; 0x81uy; 0x82uy; 0x83uy; 0x84uy; 0x85uy; 0x86uy; 0x87uy; 0x88uy; 0x89uy; 0x8auy; 0x8buy; 0x8cuy; 0x8duy; 0x8euy; 0x8fuy; 0x90uy; 0x91uy; 0x92uy; 0x93uy; 0x94uy; 0x95uy; 0x96uy; 0x97uy; 0x98uy; 0x99uy; 0x9auy; 0x9buy; 0x9cuy; 0x9duy; 0x9euy; 0x9fuy; 0xa0uy; 0xa1uy; 0xa2uy; 0xa3uy; 0xa4uy; 0xa5uy; 0xa6uy; 0xa7uy; 0xa8uy; 0xa9uy; 0xaauy; 0xabuy; 0xacuy; 0xaduy; 0xaeuy; 0xafuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_info : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0xb0uy; 0xb1uy; 0xb2uy; 0xb3uy; 0xb4uy; 0xb5uy; 0xb6uy; 0xb7uy; 0xb8uy; 0xb9uy; 0xbauy; 0xbbuy; 0xbcuy; 0xbduy; 0xbeuy; 0xbfuy; 0xc0uy; 0xc1uy; 0xc2uy; 0xc3uy; 0xc4uy; 0xc5uy; 0xc6uy; 0xc7uy; 0xc8uy; 0xc9uy; 0xcauy; 0xcbuy; 0xccuy; 0xcduy; 0xceuy; 0xcfuy; 0xd0uy; 0xd1uy; 0xd2uy; 0xd3uy; 0xd4uy; 0xd5uy; 0xd6uy; 0xd7uy; 0xd8uy; 0xd9uy; 0xdauy; 0xdbuy; 0xdcuy; 0xdduy; 0xdeuy; 0xdfuy; 0xe0uy; 0xe1uy; 0xe2uy; 0xe3uy; 0xe4uy; 0xe5uy; 0xe6uy; 0xe7uy; 0xe8uy; 0xe9uy; 0xeauy; 0xebuy; 0xecuy; 0xeduy; 0xeeuy; 0xefuy; 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy; 0xfauy; 0xfbuy; 0xfcuy; 0xfduy; 0xfeuy; 0xffuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_len = 82 let test2_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x06uy; 0xa6uy; 0xb8uy; 0x8cuy; 0x58uy; 0x53uy; 0x36uy; 0x1auy; 0x06uy; 0x10uy; 0x4cuy; 0x9cuy; 0xebuy; 0x35uy; 0xb4uy; 0x5cuy; 0xefuy; 0x76uy; 0x00uy; 0x14uy; 0x90uy; 0x46uy; 0x71uy; 0x01uy; 0x4auy; 0x19uy; 0x3fuy; 0x40uy; 0xc1uy; 0x5fuy; 0xc2uy; 0x44uy ] in assert_norm (List.Tot.length l == 32); of_list l let test2_expected_okm : lbytes 82 = let l = List.Tot.map u8_from_UInt8 [ 0xb1uy; 0x1euy; 0x39uy; 0x8duy; 0xc8uy; 0x03uy; 0x27uy; 0xa1uy; 0xc8uy; 0xe7uy; 0xf7uy; 0x8cuy; 0x59uy; 0x6auy; 0x49uy; 0x34uy; 0x4fuy; 0x01uy; 0x2euy; 0xdauy; 0x2duy; 0x4euy; 0xfauy; 0xd8uy; 0xa0uy; 0x50uy; 0xccuy; 0x4cuy; 0x19uy; 0xafuy; 0xa9uy; 0x7cuy; 0x59uy; 0x04uy; 0x5auy; 0x99uy; 0xcauy; 0xc7uy; 0x82uy; 0x72uy; 0x71uy; 0xcbuy; 0x41uy; 0xc6uy; 0x5euy; 0x59uy; 0x0euy; 0x09uy; 0xdauy; 0x32uy; 0x75uy; 0x60uy; 0x0cuy; 0x2fuy; 0x09uy; 0xb8uy; 0x36uy; 0x77uy; 0x93uy; 0xa9uy; 0xacuy; 0xa3uy; 0xdbuy; 0x71uy; 0xccuy; 0x30uy; 0xc5uy; 0x81uy; 0x79uy; 0xecuy; 0x3euy; 0x87uy; 0xc1uy; 0x4cuy; 0x01uy; 0xd5uy; 0xc1uy; 0xf3uy; 0x43uy; 0x4fuy; 0x1duy; 0x87uy ] in assert_norm (List.Tot.length l == 82); of_list l /// Test 3
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Spec.Hash.Definitions.hash_alg
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.SHA2_256" ]
[]
false
false
false
true
false
let test3_hash =
Spec.Hash.Definitions.SHA2_256
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_mul_u
val bn_mul_u (#t: limb_t) : bn_mul_st t
val bn_mul_u (#t: limb_t) : bn_mul_st t
let bn_mul_u (#t:limb_t) : bn_mul_st t = match t with | U32 -> bn_mul_u32 | U64 -> bn_mul_u64
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 165, "start_col": 0, "start_line": 162 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j) inline_for_extraction noextract let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) inline_for_extraction noextract val bn_mul: #t:limb_t -> bn_mul_st t let bn_mul #t aLen a bLen b res = [@inline_let] let resLen = aLen +! bLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@ inline_let] let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in loop1 h0 bLen res spec (fun j -> Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j); let bj = b.(j) in res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res ) [@CInline] let bn_mul_u32 : bn_mul_st U32 = bn_mul [@CInline] let bn_mul_u64 : bn_mul_st U64 = bn_mul
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Multiplication.bn_mul_st t
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Multiplication.bn_mul_u32", "Hacl.Bignum.Multiplication.bn_mul_u64", "Hacl.Bignum.Multiplication.bn_mul_st" ]
[]
false
false
false
false
false
let bn_mul_u (#t: limb_t) : bn_mul_st t =
match t with | U32 -> bn_mul_u32 | U64 -> bn_mul_u64
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.nat10
val nat10 : Type0
let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 35, "start_col": 0, "start_line": 35 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) let scale64 = s:nat{s <= 256}
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple10", "Prims.nat" ]
[]
false
false
false
true
true
let nat10 =
(nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
false
Spec.HMAC_DRBG.Test.Vectors.fst
Spec.HMAC_DRBG.Test.Vectors.test_vectors
val test_vectors:list vec
val test_vectors:list vec
let test_vectors : list vec = [ { a = SHA1; entropy_input = "7cad65e5cc2888ae4e960f5d143c1425"; nonce = "fc0785db471cc55e"; personalization_string = ""; entropy_input_reseed = "66451d29cf65d899a281905ff9b29e87"; additional_input_reseed = "800d583b2560d2a2300132ee2d13f19f"; additional_input_1 = "42eae705c2225d212fa0554ac6ac564b"; additional_input_2 = "72081e7e70200f1982c3ad9cb1d3ddbe"; returned_bits = "953e92258be7ff61b97077252ab9835231e366dfa5b635fb889c337562a2641d3aa9e46feeb2a4ea03cb73f1f801594c3cc71d2945c11a52bb0e93419df5d0854ad5f2e36d223c119e145cad507495a7"; } ; { a = SHA1; entropy_input = "0736a083595a8397cb9e676cb37bfb5a"; nonce = "0b184a6d0a630abb"; personalization_string = "c302503d86a2bde46a0c63561a86cfd9"; entropy_input_reseed = "4b50977033483277647945ffefa109e2"; additional_input_reseed = "4dad813744f54324b3046a85be3cc3c8"; additional_input_1 = "7441fefa60f7ee48ff387b587efcb3e6"; additional_input_2 = "f0d005289a9d3993c44bb750d96cc1bc"; returned_bits = "c03971897b854585994eeb8e3d6b556e1a8df18a7ff88f83e8fe17e6dd9071070a6dbef67cb612acf122caa7f817704b3efc6e1b1fd6c330e0a732abea93c00818e12c504fd8e0b36c88f84a95b49362"; } ; { a = SHA1; entropy_input = "172054c827aa895fa1239b7a484752f2"; nonce = "edb272c0a98c7592"; personalization_string = "47bc78bfbd1bb7e2dcdbf4ebe42c5293"; entropy_input_reseed = "29f92a0e5d24e19af698877f69a0efb5"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "6464bdaed23245db1f6510f8659e1b19881d606220997b837684a7f88a166cb75ce6829cb3f11e55d2b7ad349cc1f4ba02e30a76f970613aa74635b0034f8e985cde4f1fddb964657a169386e20767d1"; } ; { a = SHA1; entropy_input = "b1a19bb07c30ca4f49dc69130d23c0a7"; nonce = "2c06067297058ec5"; personalization_string = ""; entropy_input_reseed = "840802cea2e55a3b1e487bb7aee62b42"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f41bb7ae532344a90d413b66a94ee1d0254a5d5e974e36b1993b1042586f54728d1ebb7c5d351558ed675177e432360708c008984c41bc4c828d83ddeca9ef8ecd9da880a135400a43f91f4ca6d59d00"; } ; { a = SHA1; entropy_input = "343f9dde89a9e3ecc4f9653c8b392dab"; nonce = "c4fb3606d8f62db1"; personalization_string = ""; entropy_input_reseed = "021fc3ead46ff8bda3b79701b7893a39"; additional_input_reseed = "8918831e15d430616f4bd91046fe0930"; additional_input_1 = "a8772304a1accb16662218a748bb4fd8"; additional_input_2 = "4bf9f2b9d15ec3071ff3674ad7418759"; returned_bits = "9782b2111c985bcaab0b8905ad9bcb97eb3f3554c68d79ee5ca1dcfbd0d7850f65090c79d21d1c6253cf493f08392cfb60461fbc20beb4cf3e022123816f0bc597abebc775633db324c7c1c7cd5e8c56"; } ; { a = SHA1; entropy_input = "0a086726f66f2ac9e7daa61908f63319"; nonce = "debf011d406a5b23"; personalization_string = "58582da74f8f91db0444beae39016857"; entropy_input_reseed = "c92ba2900ab0a4ca3553806392b6b3e5"; additional_input_reseed = "5604a76e74ef4b304466f21df57c70f3"; additional_input_1 = "e1e4d0754cc306a1752b50c5c446a3d0"; additional_input_2 = "71dacf61875cbf3655e4f7d2e081d493"; returned_bits = "afbb3a05e753f6ebf026594a03b22b3f032edb873b9e1e22532e360a097d7e0d4585bbf82f9b12d7a88630efcadeb8ffdc8b7c8a53fe94eea9d2cd6cf90828c3511fc936222ba845fc77995a03855578"; } ; { a = SHA2_256; entropy_input = "14683ec508a29d7812e0f04a3e9d87897000dc07b4fbcfda58eb7cdabc492e58"; nonce = "b2243e744eb980b3ece25ce76383fd46"; personalization_string = ""; entropy_input_reseed = "18590e0ef4ee2bdae462f76d9324b3002559f74c370cfccf96a571d6955703a7"; additional_input_reseed = "9ea3ccca1e8d791d22fcda621fc4d51b882df32d94ea8f20ee449313e6909b78"; additional_input_1 = "16366a578b5ea4d0cb547790ef5b4fd45d7cd845bc8a7c45e99419c8737debb4"; additional_input_2 = "a68caa29a53f1ba857e484d095805dc319fe6963e4c4daaf355f722eba746b92"; returned_bits = "c4e7532ee816789c2d3da9ff9f4b37139a8515dbf8f9e1d0bf00c12addd79ebbd76236f75f2aa705a09f7955038ebff0d566911c5ea13214e2c2eeb46d23ad86a33b60f7b9448d63eec3e1d59f48b39552857447dc5d7944667a230e3dbfa30ca322f6eacaf7536a286706a627c5083c32de0658b9073857c30fb1d86eb8ad1b"; } ; { a = SHA2_256; entropy_input = "a1d5bb7d70621dee6b668b28c56d5610c2f8ced30284cc3e0e48de331af05062"; nonce = "88a49e3e54c5ea54c98b95de81bcc807"; personalization_string = ""; entropy_input_reseed = "b4e2426e98f6eed97a6cdf690a89ee109e84c3dca16c883c26fa4ac671638d8d"; additional_input_reseed = "5bd1e086ed228cfd8b55c1731fea40c3a63d022599ca2da4bb23118f4821ba62"; additional_input_1 = "b754b53ac226e8ebe47a3d31496ec822de06fca2e7ef5bf1dec6c83d05368ec3"; additional_input_2 = "fa7e76b2805d90b3d89fff545010d84f67aa3a2c9eb2ba232e75f4d53267dac3"; returned_bits = "df6b2460688fa537df3ddfe5575fca5eb8abad56cbc4e5a618a2b4a7daf6e215c3a497974c502f9d0ec35de3fc2ea5d4f10de9b2aee66dcc7e7ae6357983095959b817f0383e3030771bd2ed97406acf78a1a4a5f30fa0992289c9202e69e3eb1eabe227c11409ff430f6dfca1a923a8b17bc4b87e908007f5e9759c41482b01"; } ; { a = SHA2_256; entropy_input = "68f21d14525d56233c7e263482d344c388a840103a77fb20ac60ce463cabdc79"; nonce = "59fa80ae570f3e0c60ac7e2578cec3cb"; personalization_string = ""; entropy_input_reseed = "7584b4166530442f06e241dd904f562167e2fdae3247ab853a4a9d4884a5fa46"; additional_input_reseed = "f6a5482f139045c5389c9246d772c782c4ebf79c3a84b5cf779f458a69a52914"; additional_input_1 = "9d37b1ce99f8079993ddf0bd54bab218016685b22655a678ce4300105f3a45b7"; additional_input_2 = "4c97c67026ff43c2ee730e7b2ce8cce4794fd0588deb16185fa6792ddd0d46de"; returned_bits = "e5f8874be0a8345aabf2f829a7c06bb40e60869508c2bdef071d73692c0265f6a5bf9ca6cf47d75cbd9df88b9cb236cdfce37d2fd4913f177dbd41887dae116edfbdad4fd6e4c1a51aad9f9d6afe7fcafced45a4913d742a7ec00fd6170d63a68f986d8c2357765e4d38835d3fea301afab43a50bd9edd2dec6a979732b25292"; } ; { a = SHA2_256; entropy_input = "1ae12a5e4e9a4a5bfa79da30a9e6c62ffc639572ef1254194d129a16eb53c716"; nonce = "5399b3481fdf24d373222267790a0fec"; personalization_string = "8280cfdcd7a575816e0199e115da0ea77cae9d30b49c891a6c225e9037ba67e2"; entropy_input_reseed = "681554ff702658122e91ba017450cfdfc8e3f4911153f7bcc428403e9c7b9d68"; additional_input_reseed = "226732b7a457cf0ac0ef09fd4f81296573b49a68de5e7ac3070e148c95e8e323"; additional_input_1 = "45942b5e9a1a128e85e12c34596374ddc85fd7502e5633c7390fc6e6f1e5ef56"; additional_input_2 = "6fc59929b41e77072886aff45f737b449b105ed7eacbd74c7cbfedf533dbeaa1"; returned_bits = "b7547332e1509663fcfea2128f7f3a3df484cd8df034b00199157d35d61e35f1a9d481c7d2e81305616d70fc371ee459b0b2267d627e928590edcac3231898b24ef378aa9c3d381619f665379be76c7c1bd535505c563db3725f034786e35bdd90429305fd71d7bf680e8cdd6d4c348d97078f5cf5e89dee2dc410fad4f2a30f"; } ; { a = SHA2_256; entropy_input = "10b8789cdbd6778442a45edf228b9923f452631ad0fe9e608d10826ba71da7ca"; nonce = "159fc5d8e50eb56e22974789b1dc20d1"; personalization_string = "2dd59e37766c667571b779c06e12ba219188489772f48631a6728b5b867e3cf4"; entropy_input_reseed = "966d942038030509b20e610062042b6bf104812818893292a68d57d1ce865151"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "3e6acd8b4e85b4a0f7928f6bd41a8e6b52524fe72723a0509637d33f15afe7d8da6a15209b9e4149576fbb1fd831f784c04439abda4605d06556dc3002055b5855fba201f6daef79f78d001ed69eca8a418513d02464e8d742c2799cd68edfbe88ae9b35a0aa065c42a4770058c4b026d0350a7afa9c52c3c7fa054f8a96d887"; } ; { a = SHA2_256; entropy_input = "e5fa73bed99340c91ab17d039efd248fcd1ab8b0a0f655dd3149949685ecadbd"; nonce = "af4b94f08300a1eb059ad6a687a22fd1"; personalization_string = "d0095a4fd7f6d6de2a1f0b292c47ece8565bf8c202f0723d0de7f2f7904537bf"; entropy_input_reseed = "4dd81fad534aa36e174d06666e95a4d9b3622bf60d8a562c764541ea7c974fe9"; additional_input_reseed = "117ca0aa9d57973005fad1f8a02f2d62ac701758556b42a8d5382ee55540a86b"; additional_input_1 = "a36ba41e095a40f37985a5cd7315f3773132f491ef8a453d3970ae72f41c5365"; additional_input_2 = "abba1d162556eaab729252cd48dead2d7d50a6385b1d270591d465fa38c5597d"; returned_bits = "2bef01bea1fb0ab5fccbb474a1bacb361ffcc326f1d9f1969048c392f2761ed0a37126433311dec9db18596448cb814eda151b264e3ca464b25de401b0e38b43e93c64f675f37ad91e95c24e6997dc4032fa62ba00f3c8a792d6b539a4e8290b10173b6b35f7278f34f40df7c4cf26518350dfa7e24362320c8446963a9a1369"; } ; { a = SHA2_256; entropy_input = "0c2c24287f264c1d5329d18989e7f9ce06b8a9446d26cd90ed718792b13dad94"; nonce = "fd01d038386b37709f8da03579f82bcc"; personalization_string = ""; entropy_input_reseed = "05b523ccf880bfb0da83a05e4eb2ea28cc75a1e4f9e09c8a3959b18622453bdc"; additional_input_reseed = "85e06a8ca3a741821c3a2a8818131675136efd5841cb96e7ddec7943cc169fa3"; additional_input_1 = "6b842e1cfdcc6203fa3750cfb3c722f7a85014c06e78da8ea61f0f9e7c20cb4a"; additional_input_2 = "7ba4a1494a0b498388f94d1726b8baf63e44a03c2bfbbff35ad039b39881720a"; returned_bits = "b1001e78fdb26dc92e2389ec0eb5eb3059f44ab4f2ead6c74a7615ab8687381898f5b0d838247f41786bb83c077713ff84540ed54061f4d00264699df476873c0dd0c363b998054edc64084efeed7dcf28d7719979978448d7dce8f8aa3868e56b89eebf275f000a39c4cfb5af16a64302a90986cc3042d8826f2e3f7fdb859d"; } ; { a = SHA2_256; entropy_input = "c13d6cd63bb7931174696f3e04a0c41cb0b2561134e847ce03e36326b803f8ab"; nonce = "2084ab32374392ea9f6e8a474f18e9d7"; personalization_string = ""; entropy_input_reseed = "aec5a6a7232a52b81ce7e981a359cef1bbd2f1eff8488371468cd1f4147a89c2"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "daea78881737cb26d60c36ceb9fec3d281c7aec54b4b9850937b373b2b2621fe077585a1fe88265d84f225552e5c85cbec8d00069648065ac12073aedce8c940460949b597667ecfcedabd7a86a979b904a24d32db10223eae5a98a0d1b6571b8643df2c6265a5d66cee9f4abfc5778146d6fb2b853d82636c1325b2d1ef4576"; } ; { a = SHA2_256; entropy_input = "88a76c16d3270ed3fcd176f9d793fa0c35516574c1cef425b6007628afa35e2b"; nonce = "ff16cf7cb8e49d482cfd3994abc5ef8a"; personalization_string = "9213c54e3d002df8741163ab9d7e0757cd512c691ad64bafef95cb72539b0ac6"; entropy_input_reseed = "493b647ff0b3faa2921f12f8f57b919329f2af2fc1f14576d9df2f8cc2ada7a6"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f1330a85f90037876b3749203e849287444a827f0a58c249ff868fc1adba4dce285e076a1f8ae1da8cf9fe14931e8164186c97a8feaf24583451f116e65f8e432e7ed55a36683120377e23128dca1540fefbf3af1b56d5c74187f5286d0a95fb55931770543060ce8df08f3c1959a1f4fc36b64671e0654fffe70d96d521be21"; } ; { a = SHA2_384; entropy_input = "e8e99ffcf08aad8e50386f5d079d79d3db783a74165c6126b42b3140f744a7c7"; nonce = "23541930c8c772adb62981dbef8d054e"; personalization_string = ""; entropy_input_reseed = "cdcf1c30228904bd7ba31798bfbbd64757aa251ac9a1ae8c20a050670feac59b"; additional_input_reseed = "546e04247d6cb5212a57b62f99e1cca767a5768cf79296f45f0db24732ba6368"; additional_input_1 = "fd45f66c8dede41387373c38674605f3e075c9b7cfc66123a5478b8f8e3ab276"; additional_input_2 = "39911a79c6edbbc805a50d2aa018742094177a8e216d647c64428c00169ab2d6"; returned_bits = "871577ddf34b29e5caf132aa82e1d2f1586b76e39aab62acd02f6d4440908a772ac5f6fd48c5f55f1ebe0e76221ac46b834a8a4f5dd9958721ee053ba3aef1574ebd980a5da6a94693662717ee548af0f921421d1afb814e4d1799d351889d2a1bdd57570a913e428e6613b16e158c1cfed038f6578920d60db73dc10a40da9bc363a0206b4e7e49670eccea866efd9a05bc237042cf052f2a4140f9377e3c6792b88ea06323fcebb99c643fc1c3653758d6866cdb148837fb0fdf77de1564cf"; } ; { a = SHA2_384; entropy_input = "9319148fb7c2389793e9f53cd3b4ad8f1bb75710088f1c9a18434ce13b190da2"; nonce = "11fdc53c13aea33985ba2678e8d86d09"; personalization_string = ""; entropy_input_reseed = "8619290e975f1c50f6606c7027efe9c8438d3209db71edd023af0eb024a282d2"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "30c2327eddb5c3942d90006eadccfc26d27b149f195389abba507c0746e41d7fb8cf30c15f2cdff73ff3d77b4ca0d289f0660073f2c73f83ce819a6a7d8fe911fd109778b501357eca73079d86bed0916deede54e2e86eca2c04f3d0706e2a55ff84942cbfee22b5a92d309b84b8dd3decb9f3f2c4b24efb4f382833ffb867b5fe054b21d47db6c52ff52faa13ce2abdf7996e23a8c96bac48c02980d96234e478370027d55ba8752c17c7a1bf6253084654e79c13bacc51c1815c8b647e36cb"; } ; { a = SHA2_384; entropy_input = "f9e25060675e4c5734d818d9c31a0b232474520577e42f8c53f803aee2349f4a"; nonce = "9a62a41cf3f5a9e198dff8c907a35a3f"; personalization_string = ""; entropy_input_reseed = "888a7529909ae36053c75badb44d103118e171784a7b67dc0d7a4e1b1d44391a"; additional_input_reseed = "10a25d0027b1c55f615d3b7c3f235d791a81dfe8215315e0c38fccde27a5d8da"; additional_input_1 = "7b10e25044abd0917490e7f1a8cfd24966803fc9be260f3ab5bf954693f60885"; additional_input_2 = "a3563ec5c089fff127b2a2eaef12bd0cb3b18f3a0999754666113a052fd443f9"; returned_bits = "83b9fef4f31c71aebf3753d0404208678987fc4cb2d293a8ac8a547aed18a7a9e09d8196a07d6e97c909e64aef00d9b9530ca1cd69d65807857d9b30a74924a6be96dd96fc48ad5931892736a77f62f68c3fca75af3e2ea5b2a336f1e080a24fa28f81fd8b1a34d3c8aac650acaad25ed1e00bc44092a13940c821942add18bf0ed70c578c305711b0a4991ec5bddfaecee804619b197fd716aa2e6713c0cf91ea0a6d46a4d0ea80a7f70f4fc75307d342e69d1fdff989808b7500275cd05218"; } ; { a = SHA2_512; entropy_input = "58ebcec4539f4af1b32a854181dd0f512b8c704fa47537096a769eff28c59165"; nonce = "a18226cfc779efc9550f7be02006d83c"; personalization_string = ""; entropy_input_reseed = "230cd6e6909e301d1e99ecd1fff2b2cd00a56c7a684c8907bbb13ce3e9a0cbce"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "6f4e86f309f69144603961c5366e4f9b16d10c10593ea689a8e7435a327d2524f4468813ea7f3248d8d4bbe17b175cfc40617149983928b267dc0c4db46d2c17fe8bc0764386758af1a824e12eb897feafc1c7ef66f80ffcd993aa016e139991cde8435ee6bb0de45a7fb61eb1a6beb76e012b848ea003f687537e4bd00ced37efdda66333b53a8dd5220c281fbf68bfd9e72285e78197881efc540da4c1ba80a226013a2d7098d34af4112e7b8c865af15409f6901b952fee4a474e4027051e1dce879ddf5e84f3947dc9b94119d67e6b48ed6fd6b1f813c13d3ff30e121efce7918533925f50c8e381e87ea685f993619bacc9efc0aebc884b450646eeaa5e"; } ; { a = SHA2_512; entropy_input = "e1d2d72e7907e7214cb266f1ef641395e54b39e8365304661b0bee371f324652"; nonce = "8417ffd58420e48ec063de5df4462e39"; personalization_string = ""; entropy_input_reseed = "e6cae1b5f3a3a12faaaf39b98ee592c8d4f56b9d4534add5104b357d788c23ab"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "626a0863321ac75e0b6240ea6a619458634a978245c1533819c97114e63914009c9cab732f1310f60f64f033b00729424228671f33425099820ab108412d460f32c0015b73987e937b9bbdd29e5bfb8dbb6c95d2b69fccbc26b060cf0a5dc0992fb0e76b38bcd64fd7a726714e8c8542d44b2f9c5d2f2f8cb370b95e086b07e88f492f51fe6c288d78b76d0c3a6146c9dfce53e76cdbbd158d2944dd10197247004954d92f6b1df4badeb4bb1c98d7d3da2054e3300f6d8dda8863422e6a042c2d84b2bbed6be88f0704763410771b3786d2f6d968b6c224e0cf535e8d02c178b2e0b90e8a7fca0c431b7f3cf41b0a7c17778fe8c2eeb442c910ba88c7c364cd"; } ; { a = SHA2_512; entropy_input = "47c42df62b4dd570efd3c2722ad39a2df5f969a13f645fd27b5290877ba70916"; nonce = "c591934d4f66000ebf8c508fafc44f75"; personalization_string = "94822903cb5c2003c31c6d072ab0dda435add0de7d8f9d5f08b5cba410d888fd"; entropy_input_reseed = "d16a2c72c63580b9bcf156862214533a47b1686c871a0165604fdd00a412a484"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f78e61b443b5a97b7e493a8ce35a43545290dd33d15ba4bf0ff78f34a25c46c4ff4cd485964cc96e90fe847d9fc9e42d96e4f5aaccf976a84e3e12100c28b0f7addb1c76f89663e11890f09e4beefe928a1e0b304f1d9dd0414cd115a01b641fd69c7071f2ca7c7f2e53560f4e91010ba11948195bc5deb556686feb0bb92fe61b3171e639ef47418f02be37796efdb6920952f3a8c766b52fccfa757e923e38028a84f9be1b802c1fbbbb4aef825f4c5e4fc1bf6e96f33ab90ea486710718c9e4f3247b2a55ccef5a5d342cac757f0b9f90bcdcc8c2ec3a43149bbd3924c85f0b5b7ae42151f4ded826ee6d47849ef4e8af64adf6863982503c23c4a0514ce0"; } ; { a = SHA2_512; entropy_input = "f840c75ce0cdb200a3bd980d6cedf1c7321e5f303cd0446c7afd2d2d66657447"; nonce = "b215333b15d55326bc9bebae6ae36efe"; personalization_string = "6d5ca4b1edf6c0afbdce02ecb30923b2f4f2b33121e21b2ffee964cc7de1abe8"; entropy_input_reseed = "a3a337c6fbeb6a979a4783f2b7f0f0dd6d3a9d3747de639a9047248a04a19f5b"; additional_input_reseed = "f56d2b1584ba2f129c77b29590c4e1dfdab5527b1791e3e445750ca6d4ae3542"; additional_input_1 = "05bd799249411b37b80590d49f3348631b06a2408a61635c70687003a8485302"; additional_input_2 = "12d26ac3b87924cda5d78a3e3c0bd81280e340723643ed1b2ebf2dfd52f5dc43"; returned_bits = "b48c13af7a9b6fa6385a7ee5d2ab97dcebf71a715dc465f413cb0962292df84c9c83c4093309f749359b0a0ddcc13162cb4ab8ff7b3a6336351ed79ebf47730f97accb6a960a9c5c25e0920a06cccc3b3f62b616c15ca18d7e0b5c2e7d8ad2518d1ef0bef515af866893e9378b56deec32825fe0a2c5a9729f658915b99ab22a03b7187e83d2d0f41b9467c8326f7bc87189dd8ade18b3a7edf0c0ea462dc22109ec91294cf8ce69c8cd0c129b423edadda8fbd25f4983a70d75001576a26405188bb0284975203694c318f3aa7fe47ec041bc4c11c9bceb1b131f74adcd72fc4d2813564de6d4711017800377be9e4c579e88464d67ea6e457a30f8f652375a"; } ; { a = SHA2_512; entropy_input = "46dfb4e82fc784ad0094dc81136834e5abc767fff2b876a06b1dbd2508dbed3a"; nonce = "64d40d3886ac152838f6853121fd68b7"; personalization_string = ""; entropy_input_reseed = "329004b8bb439305c4b2dcdd54ca97a4f54cb720a8582cdc03ac26f8a603f3fd"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "1887eb4c57b63109f7e446bf0a6c598de093a6013009503925d620f40cf98c8774a6c4a1affe57f8e6b190d0504ff4c4eb55ba4e8a2642d230ee845ed4e31d8adddb1a21dd45346cbda9884a322e6e8f38a82e888f81264a2e254ec2ad5ad4d60a162287e48bc39776eb57dce88cfe467b042d037d1b06877acc39f31b08b1aa13805fe0440a3506a7f59dc6e2376147acf87b78bbaef4c15b579335794688d142eedc231829a34a5c6976e0c8c4649edc178c8f7d8f9ae92f05e3d54df6e47cf9260a5a582a7d3b0030e9a5de912d0f7e4d3103233dcfa8dc0caeddf12a8502c7d941de883690d47bd1a1b61d723abaf0c31d67136fb427edcaa9526a9dc9fa"; } ; { a = SHA2_512; entropy_input = "12738c0ddd0c9ce0393d2acabdfa592286072a362e332ca3f8c401f01d610026"; nonce = "b983dcfd4af5e451f6efe155fcf3ec14"; personalization_string = ""; entropy_input_reseed = "07c8b69898caec3a1104e2e30b811ea095384cc636b9bd24e0f9837d3b8e0b4c"; additional_input_reseed = "fee06814eab6e55cb799e815d84f07278ec6c12d82dea12e261c5b72d0a4eaa5"; additional_input_1 = "f29287d46d517f090df11af46703d5de778028c787a3aa1e5904ed737b776912"; additional_input_2 = "0ce576cae56c46042ff27f9f11ed88f1ba534cf5f2581e5ad6bb69b642897886"; returned_bits = "6293103d028540484c262770ecf7c47c93e778daeda0a5d17a838a5933871af041ac603d81c4a8d73f4cacff06cee74424b57e8440e83939509ea1861adcaa29332bbce015c2b4d6c74154b52a6de9b4c5ec9edb4f54b7be42142b9be07bec5052b78bbc4bb742ee89f0399071f49a73df87b3fe762d1656346c9e8bf8e4b4b8b55e4e1ff23662b6586bf0f105e9d001f1593c175c9a234cbb17cfdafd90ba85f347cb79b0046fb5715bbf35f08345c8fbc26e4722425f04ba431c48ecffcacf15d09ea5abda92f541e46bb63e3933a2c053be4565275d34fa085baf555f92f446ba5e5d05fa0c63c53042092cb66c406d9b6b36b00e76d51b49b75c36e41e52"; } ; { a = SHA2_512; entropy_input = "6a2baf90d2e8b83355a0230a8fc7237c140f7699f40026e276deaefd4faa8e06"; nonce = "b2eecce638bd9fa485e9c9e0d94c3a78"; personalization_string = "a9ea2c4b2aba1f48f2c71ae1a7fee90e073912c833f2de9c5f802ac2ddc57fbd"; entropy_input_reseed = "820fc963827166de710208a7dc33936471e491fc21fb0119a252b49fefb28a01"; additional_input_reseed = "9a463484d172108807c43c048bd13a72d15b470c3443390774a55572d03f47b1"; additional_input_1 = "d98671978ae14b3531394a0785f78242d4b32eb61cffec6088efb8625693276a"; additional_input_2 = "b9aef32c40b7aa4fd732e4431bedce071e4f64405be1c85de03c7faa0aa7270f"; returned_bits = "f55791fdc9d763c34c0fc4cc457a438496f18f483cc60c493fcd0549812fad792f92381532548a8c2257c6e424fa570af260bd47de92f248f57291fead3a68c94be9dc12a656630622be9b602d4fc5037c29bbb5fa92fed2235186048f652131f845f01ed718baf05957e863239e94a5613aa47dd25d5bc9f170e4047e86ef1eefa60e359f2204a3f453c9b37dcfd9410736ee14e296abcdc185f3ed31d8ad461a81479f957e69c34334a24e22f4a69606db8bca6cb189e7de4b83d8a10461fba1942c83aa2e5f84dced9440f10a54c74153643287313ae7fe1bf23c6abecc55c4a3f5540495b7d29a302d426ee2f13dd9ed7a5a6618724544da63527c702e4c"; } ; { a = SHA2_512; entropy_input = "47139f544af9f6b0b8022bbae5b936a3f4bf8a0f1cd10c8c5fb8bb7363df6411"; nonce = "b99640f70c7b55605f7bee6753f30675"; personalization_string = "0f88357519e8f2c05495c595056e6023460bea47e79f72b113784eb6a77f9f28"; entropy_input_reseed = "83ed7fb5ae85138161fe90b14b15295b11d81b0ecbd9f1838a2858cf9e822886"; additional_input_reseed = "e973ea2d399b9c4ad685411a619b7a5ce6f6568bc66efb8855a69f256829a62d"; additional_input_1 = "1bd8090104b78844f6d615e93b7ae0c921517c97735c0aaa28cdee1eb0a14659"; additional_input_2 = "4d57d04fc0a2adc6ebb618f1236fee0eb00e38ff82137f5e375be00ad1aac35e"; returned_bits = "8c4ce3292ae500557b40e4215665c8db5ccba13fbd2d26ca8d1fdad9dca158371ec0003cf801fd28741a2fd31d15e4c0612c68e19fa4e19c626ce4b0184303f4544c414a6541c7d4ac5e6555d22e21c09a096aa9ec09c902eb67a2de9eba94b719ec1ba4dd5dbafee93fcd5125223eaae0bf0d8e7eb92ea0610cc32b69584c0a1565802028f31e6910021d618e5138137eccab894a5385ca4544fdf20919ef2216a3eaf44fdacc7fe05ce22e565a5ab013cd6c9e0a80b430fa8b72127f84f3a780d4ee92c72901eafc8a21c56dcc687ac4ce464cce068895471b36f7b58987ae3272581f00f8d667085bdeadcb06ffef5b1b329bf1db71ce101a2d694de9e322"; } ; { a = SHA2_512; entropy_input = "2886ff4e11950c1e639398b2c7d6908d5c2e4daeb7719e6dd98a39b1428ea7df"; nonce = "8cbb97f58cf243045bdadb2f9bbdab10"; personalization_string = ""; entropy_input_reseed = "f487b94b5e4eda49e933e0c268eb5042c422df88061ebffd893d39fafd58efd3"; additional_input_reseed = "ff8e7656a21bcced082972719ebf87539c4825cb0f4beabd12a12d544dea87af"; additional_input_1 = "f64dd3b0efc5c8c146f9b9b8f0ec7ccb784e87c16268a4aab31e9eddf2c9b83e"; additional_input_2 = "9dc16b955ae805f10ebbdc3794a2abe671a339ca148b46ef6ea208698a54a0d8"; returned_bits = "0e8c9cb99fec37602b291e508e43c2ab323d05764184379ca3a2ca4080ed26c2dbfdf3d1916485c7eba49077ca881fb03d07f967cad9b477959f007a6188150b6630218af55fdd7be2eb88d48b5ec6b6876ec25665c0310624283d2b5460e3736f8b9f0b84095aa4754ac59067a7cc73402c09b1768972b3abd49e0e237a741649ea7888ea4a024c0952b94af27c53b13afcaa4fb7976f65443809d1bbd7e4b741bcd6c4a3f2cdf863e719e5d5e60043e771ce5355dee1c5299ddfa54d77ddde2924271c0ece1e1e1e8aa6218c08aee40993eed58959af430c7d53b4179aa355febcc40124cb7a1d2965e36832e5f42f9a48275888725cba28d72398fbefac94"; } ; { a = SHA2_512; entropy_input = "2886ff4e11950c1e639398b2c7d6908d5c2e4daeb7719e6dd98a39b1428ea7df"; nonce = "8cbb97f58cf243045bdadb2f9bbdab10"; personalization_string = ""; entropy_input_reseed = "f487b94b5e4eda49e933e0c268eb5042c422df88061ebffd893d39fafd58efd3"; additional_input_reseed = "ff8e7656a21bcced082972719ebf87539c4825cb0f4beabd12a12d544dea87af"; additional_input_1 = "f64dd3b0efc5c8c146f9b9b8f0ec7ccb784e87c16268a4aab31e9eddf2c9b83e"; additional_input_2 = "9dc16b955ae805f10ebbdc3794a2abe671a339ca148b46ef6ea208698a54a0d8"; returned_bits = "0e8c9cb99fec37602b291e508e43c2ab323d05764184379ca3a2ca4080ed26c2dbfdf3d1916485c7eba49077ca881fb03d07f967cad9b477959f007a6188150b6630218af55fdd7be2eb88d48b5ec6b6876ec25665c0310624283d2b5460e3736f8b9f0b84095aa4754ac59067a7cc73402c09b1768972b3abd49e0e237a741649ea7888ea4a024c0952b94af27c53b13afcaa4fb7976f65443809d1bbd7e4b741bcd6c4a3f2cdf863e719e5d5e60043e771ce5355dee1c5299ddfa54d77ddde2924271c0ece1e1e1e8aa6218c08aee40993eed58959af430c7d53b4179aa355febcc40124cb7a1d2965e36832e5f42f9a48275888725cba28d72398fbefac"; } ; ]
{ "file_name": "specs/drbg/Spec.HMAC_DRBG.Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 1, "end_line": 312, "start_col": 0, "start_line": 31 }
module Spec.HMAC_DRBG.Test.Vectors open Lib.Meta open Spec.Hash.Definitions #set-options "--fuel 0 --ifuel 0" /// /// HMAC-DRBG test vectors from NIST CAVP /// https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/random-number-generators#DRBG /// let is_supported_alg = function | SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true | _ -> false let supported_alg = a:hash_alg{ is_supported_alg a } type vec = { a: supported_alg; entropy_input: hex_string; nonce: hex_string; personalization_string: hex_string; entropy_input_reseed: hex_string; additional_input_reseed: hex_string; additional_input_1: hex_string; additional_input_2: hex_string; returned_bits: hex_string; }
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Meta.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Spec.HMAC_DRBG.Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Spec.HMAC_DRBG.Test.Vectors.vec
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "Spec.HMAC_DRBG.Test.Vectors.vec", "Spec.HMAC_DRBG.Test.Vectors.Mkvec", "Spec.Hash.Definitions.SHA1", "Spec.Hash.Definitions.SHA2_256", "Spec.Hash.Definitions.SHA2_384", "Spec.Hash.Definitions.SHA2_512", "Prims.Nil" ]
[]
false
false
false
true
false
let test_vectors:list vec =
[ { a = SHA1; entropy_input = "7cad65e5cc2888ae4e960f5d143c1425"; nonce = "fc0785db471cc55e"; personalization_string = ""; entropy_input_reseed = "66451d29cf65d899a281905ff9b29e87"; additional_input_reseed = "800d583b2560d2a2300132ee2d13f19f"; additional_input_1 = "42eae705c2225d212fa0554ac6ac564b"; additional_input_2 = "72081e7e70200f1982c3ad9cb1d3ddbe"; returned_bits = "953e92258be7ff61b97077252ab9835231e366dfa5b635fb889c337562a2641d3aa9e46feeb2a4ea03cb73f1f801594c3cc71d2945c11a52bb0e93419df5d0854ad5f2e36d223c119e145cad507495a7" }; { a = SHA1; entropy_input = "0736a083595a8397cb9e676cb37bfb5a"; nonce = "0b184a6d0a630abb"; personalization_string = "c302503d86a2bde46a0c63561a86cfd9"; entropy_input_reseed = "4b50977033483277647945ffefa109e2"; additional_input_reseed = "4dad813744f54324b3046a85be3cc3c8"; additional_input_1 = "7441fefa60f7ee48ff387b587efcb3e6"; additional_input_2 = "f0d005289a9d3993c44bb750d96cc1bc"; returned_bits = "c03971897b854585994eeb8e3d6b556e1a8df18a7ff88f83e8fe17e6dd9071070a6dbef67cb612acf122caa7f817704b3efc6e1b1fd6c330e0a732abea93c00818e12c504fd8e0b36c88f84a95b49362" }; { a = SHA1; entropy_input = "172054c827aa895fa1239b7a484752f2"; nonce = "edb272c0a98c7592"; personalization_string = "47bc78bfbd1bb7e2dcdbf4ebe42c5293"; entropy_input_reseed = "29f92a0e5d24e19af698877f69a0efb5"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "6464bdaed23245db1f6510f8659e1b19881d606220997b837684a7f88a166cb75ce6829cb3f11e55d2b7ad349cc1f4ba02e30a76f970613aa74635b0034f8e985cde4f1fddb964657a169386e20767d1" }; { a = SHA1; entropy_input = "b1a19bb07c30ca4f49dc69130d23c0a7"; nonce = "2c06067297058ec5"; personalization_string = ""; entropy_input_reseed = "840802cea2e55a3b1e487bb7aee62b42"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f41bb7ae532344a90d413b66a94ee1d0254a5d5e974e36b1993b1042586f54728d1ebb7c5d351558ed675177e432360708c008984c41bc4c828d83ddeca9ef8ecd9da880a135400a43f91f4ca6d59d00" }; { a = SHA1; entropy_input = "343f9dde89a9e3ecc4f9653c8b392dab"; nonce = "c4fb3606d8f62db1"; personalization_string = ""; entropy_input_reseed = "021fc3ead46ff8bda3b79701b7893a39"; additional_input_reseed = "8918831e15d430616f4bd91046fe0930"; additional_input_1 = "a8772304a1accb16662218a748bb4fd8"; additional_input_2 = "4bf9f2b9d15ec3071ff3674ad7418759"; returned_bits = "9782b2111c985bcaab0b8905ad9bcb97eb3f3554c68d79ee5ca1dcfbd0d7850f65090c79d21d1c6253cf493f08392cfb60461fbc20beb4cf3e022123816f0bc597abebc775633db324c7c1c7cd5e8c56" }; { a = SHA1; entropy_input = "0a086726f66f2ac9e7daa61908f63319"; nonce = "debf011d406a5b23"; personalization_string = "58582da74f8f91db0444beae39016857"; entropy_input_reseed = "c92ba2900ab0a4ca3553806392b6b3e5"; additional_input_reseed = "5604a76e74ef4b304466f21df57c70f3"; additional_input_1 = "e1e4d0754cc306a1752b50c5c446a3d0"; additional_input_2 = "71dacf61875cbf3655e4f7d2e081d493"; returned_bits = "afbb3a05e753f6ebf026594a03b22b3f032edb873b9e1e22532e360a097d7e0d4585bbf82f9b12d7a88630efcadeb8ffdc8b7c8a53fe94eea9d2cd6cf90828c3511fc936222ba845fc77995a03855578" }; { a = SHA2_256; entropy_input = "14683ec508a29d7812e0f04a3e9d87897000dc07b4fbcfda58eb7cdabc492e58"; nonce = "b2243e744eb980b3ece25ce76383fd46"; personalization_string = ""; entropy_input_reseed = "18590e0ef4ee2bdae462f76d9324b3002559f74c370cfccf96a571d6955703a7"; additional_input_reseed = "9ea3ccca1e8d791d22fcda621fc4d51b882df32d94ea8f20ee449313e6909b78"; additional_input_1 = "16366a578b5ea4d0cb547790ef5b4fd45d7cd845bc8a7c45e99419c8737debb4"; additional_input_2 = "a68caa29a53f1ba857e484d095805dc319fe6963e4c4daaf355f722eba746b92"; returned_bits = "c4e7532ee816789c2d3da9ff9f4b37139a8515dbf8f9e1d0bf00c12addd79ebbd76236f75f2aa705a09f7955038ebff0d566911c5ea13214e2c2eeb46d23ad86a33b60f7b9448d63eec3e1d59f48b39552857447dc5d7944667a230e3dbfa30ca322f6eacaf7536a286706a627c5083c32de0658b9073857c30fb1d86eb8ad1b" }; { a = SHA2_256; entropy_input = "a1d5bb7d70621dee6b668b28c56d5610c2f8ced30284cc3e0e48de331af05062"; nonce = "88a49e3e54c5ea54c98b95de81bcc807"; personalization_string = ""; entropy_input_reseed = "b4e2426e98f6eed97a6cdf690a89ee109e84c3dca16c883c26fa4ac671638d8d"; additional_input_reseed = "5bd1e086ed228cfd8b55c1731fea40c3a63d022599ca2da4bb23118f4821ba62"; additional_input_1 = "b754b53ac226e8ebe47a3d31496ec822de06fca2e7ef5bf1dec6c83d05368ec3"; additional_input_2 = "fa7e76b2805d90b3d89fff545010d84f67aa3a2c9eb2ba232e75f4d53267dac3"; returned_bits = "df6b2460688fa537df3ddfe5575fca5eb8abad56cbc4e5a618a2b4a7daf6e215c3a497974c502f9d0ec35de3fc2ea5d4f10de9b2aee66dcc7e7ae6357983095959b817f0383e3030771bd2ed97406acf78a1a4a5f30fa0992289c9202e69e3eb1eabe227c11409ff430f6dfca1a923a8b17bc4b87e908007f5e9759c41482b01" }; { a = SHA2_256; entropy_input = "68f21d14525d56233c7e263482d344c388a840103a77fb20ac60ce463cabdc79"; nonce = "59fa80ae570f3e0c60ac7e2578cec3cb"; personalization_string = ""; entropy_input_reseed = "7584b4166530442f06e241dd904f562167e2fdae3247ab853a4a9d4884a5fa46"; additional_input_reseed = "f6a5482f139045c5389c9246d772c782c4ebf79c3a84b5cf779f458a69a52914"; additional_input_1 = "9d37b1ce99f8079993ddf0bd54bab218016685b22655a678ce4300105f3a45b7"; additional_input_2 = "4c97c67026ff43c2ee730e7b2ce8cce4794fd0588deb16185fa6792ddd0d46de"; returned_bits = "e5f8874be0a8345aabf2f829a7c06bb40e60869508c2bdef071d73692c0265f6a5bf9ca6cf47d75cbd9df88b9cb236cdfce37d2fd4913f177dbd41887dae116edfbdad4fd6e4c1a51aad9f9d6afe7fcafced45a4913d742a7ec00fd6170d63a68f986d8c2357765e4d38835d3fea301afab43a50bd9edd2dec6a979732b25292" }; { a = SHA2_256; entropy_input = "1ae12a5e4e9a4a5bfa79da30a9e6c62ffc639572ef1254194d129a16eb53c716"; nonce = "5399b3481fdf24d373222267790a0fec"; personalization_string = "8280cfdcd7a575816e0199e115da0ea77cae9d30b49c891a6c225e9037ba67e2"; entropy_input_reseed = "681554ff702658122e91ba017450cfdfc8e3f4911153f7bcc428403e9c7b9d68"; additional_input_reseed = "226732b7a457cf0ac0ef09fd4f81296573b49a68de5e7ac3070e148c95e8e323"; additional_input_1 = "45942b5e9a1a128e85e12c34596374ddc85fd7502e5633c7390fc6e6f1e5ef56"; additional_input_2 = "6fc59929b41e77072886aff45f737b449b105ed7eacbd74c7cbfedf533dbeaa1"; returned_bits = "b7547332e1509663fcfea2128f7f3a3df484cd8df034b00199157d35d61e35f1a9d481c7d2e81305616d70fc371ee459b0b2267d627e928590edcac3231898b24ef378aa9c3d381619f665379be76c7c1bd535505c563db3725f034786e35bdd90429305fd71d7bf680e8cdd6d4c348d97078f5cf5e89dee2dc410fad4f2a30f" }; { a = SHA2_256; entropy_input = "10b8789cdbd6778442a45edf228b9923f452631ad0fe9e608d10826ba71da7ca"; nonce = "159fc5d8e50eb56e22974789b1dc20d1"; personalization_string = "2dd59e37766c667571b779c06e12ba219188489772f48631a6728b5b867e3cf4"; entropy_input_reseed = "966d942038030509b20e610062042b6bf104812818893292a68d57d1ce865151"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "3e6acd8b4e85b4a0f7928f6bd41a8e6b52524fe72723a0509637d33f15afe7d8da6a15209b9e4149576fbb1fd831f784c04439abda4605d06556dc3002055b5855fba201f6daef79f78d001ed69eca8a418513d02464e8d742c2799cd68edfbe88ae9b35a0aa065c42a4770058c4b026d0350a7afa9c52c3c7fa054f8a96d887" }; { a = SHA2_256; entropy_input = "e5fa73bed99340c91ab17d039efd248fcd1ab8b0a0f655dd3149949685ecadbd"; nonce = "af4b94f08300a1eb059ad6a687a22fd1"; personalization_string = "d0095a4fd7f6d6de2a1f0b292c47ece8565bf8c202f0723d0de7f2f7904537bf"; entropy_input_reseed = "4dd81fad534aa36e174d06666e95a4d9b3622bf60d8a562c764541ea7c974fe9"; additional_input_reseed = "117ca0aa9d57973005fad1f8a02f2d62ac701758556b42a8d5382ee55540a86b"; additional_input_1 = "a36ba41e095a40f37985a5cd7315f3773132f491ef8a453d3970ae72f41c5365"; additional_input_2 = "abba1d162556eaab729252cd48dead2d7d50a6385b1d270591d465fa38c5597d"; returned_bits = "2bef01bea1fb0ab5fccbb474a1bacb361ffcc326f1d9f1969048c392f2761ed0a37126433311dec9db18596448cb814eda151b264e3ca464b25de401b0e38b43e93c64f675f37ad91e95c24e6997dc4032fa62ba00f3c8a792d6b539a4e8290b10173b6b35f7278f34f40df7c4cf26518350dfa7e24362320c8446963a9a1369" }; { a = SHA2_256; entropy_input = "0c2c24287f264c1d5329d18989e7f9ce06b8a9446d26cd90ed718792b13dad94"; nonce = "fd01d038386b37709f8da03579f82bcc"; personalization_string = ""; entropy_input_reseed = "05b523ccf880bfb0da83a05e4eb2ea28cc75a1e4f9e09c8a3959b18622453bdc"; additional_input_reseed = "85e06a8ca3a741821c3a2a8818131675136efd5841cb96e7ddec7943cc169fa3"; additional_input_1 = "6b842e1cfdcc6203fa3750cfb3c722f7a85014c06e78da8ea61f0f9e7c20cb4a"; additional_input_2 = "7ba4a1494a0b498388f94d1726b8baf63e44a03c2bfbbff35ad039b39881720a"; returned_bits = "b1001e78fdb26dc92e2389ec0eb5eb3059f44ab4f2ead6c74a7615ab8687381898f5b0d838247f41786bb83c077713ff84540ed54061f4d00264699df476873c0dd0c363b998054edc64084efeed7dcf28d7719979978448d7dce8f8aa3868e56b89eebf275f000a39c4cfb5af16a64302a90986cc3042d8826f2e3f7fdb859d" }; { a = SHA2_256; entropy_input = "c13d6cd63bb7931174696f3e04a0c41cb0b2561134e847ce03e36326b803f8ab"; nonce = "2084ab32374392ea9f6e8a474f18e9d7"; personalization_string = ""; entropy_input_reseed = "aec5a6a7232a52b81ce7e981a359cef1bbd2f1eff8488371468cd1f4147a89c2"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "daea78881737cb26d60c36ceb9fec3d281c7aec54b4b9850937b373b2b2621fe077585a1fe88265d84f225552e5c85cbec8d00069648065ac12073aedce8c940460949b597667ecfcedabd7a86a979b904a24d32db10223eae5a98a0d1b6571b8643df2c6265a5d66cee9f4abfc5778146d6fb2b853d82636c1325b2d1ef4576" }; { a = SHA2_256; entropy_input = "88a76c16d3270ed3fcd176f9d793fa0c35516574c1cef425b6007628afa35e2b"; nonce = "ff16cf7cb8e49d482cfd3994abc5ef8a"; personalization_string = "9213c54e3d002df8741163ab9d7e0757cd512c691ad64bafef95cb72539b0ac6"; entropy_input_reseed = "493b647ff0b3faa2921f12f8f57b919329f2af2fc1f14576d9df2f8cc2ada7a6"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f1330a85f90037876b3749203e849287444a827f0a58c249ff868fc1adba4dce285e076a1f8ae1da8cf9fe14931e8164186c97a8feaf24583451f116e65f8e432e7ed55a36683120377e23128dca1540fefbf3af1b56d5c74187f5286d0a95fb55931770543060ce8df08f3c1959a1f4fc36b64671e0654fffe70d96d521be21" }; { a = SHA2_384; entropy_input = "e8e99ffcf08aad8e50386f5d079d79d3db783a74165c6126b42b3140f744a7c7"; nonce = "23541930c8c772adb62981dbef8d054e"; personalization_string = ""; entropy_input_reseed = "cdcf1c30228904bd7ba31798bfbbd64757aa251ac9a1ae8c20a050670feac59b"; additional_input_reseed = "546e04247d6cb5212a57b62f99e1cca767a5768cf79296f45f0db24732ba6368"; additional_input_1 = "fd45f66c8dede41387373c38674605f3e075c9b7cfc66123a5478b8f8e3ab276"; additional_input_2 = "39911a79c6edbbc805a50d2aa018742094177a8e216d647c64428c00169ab2d6"; returned_bits = "871577ddf34b29e5caf132aa82e1d2f1586b76e39aab62acd02f6d4440908a772ac5f6fd48c5f55f1ebe0e76221ac46b834a8a4f5dd9958721ee053ba3aef1574ebd980a5da6a94693662717ee548af0f921421d1afb814e4d1799d351889d2a1bdd57570a913e428e6613b16e158c1cfed038f6578920d60db73dc10a40da9bc363a0206b4e7e49670eccea866efd9a05bc237042cf052f2a4140f9377e3c6792b88ea06323fcebb99c643fc1c3653758d6866cdb148837fb0fdf77de1564cf" }; { a = SHA2_384; entropy_input = "9319148fb7c2389793e9f53cd3b4ad8f1bb75710088f1c9a18434ce13b190da2"; nonce = "11fdc53c13aea33985ba2678e8d86d09"; personalization_string = ""; entropy_input_reseed = "8619290e975f1c50f6606c7027efe9c8438d3209db71edd023af0eb024a282d2"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "30c2327eddb5c3942d90006eadccfc26d27b149f195389abba507c0746e41d7fb8cf30c15f2cdff73ff3d77b4ca0d289f0660073f2c73f83ce819a6a7d8fe911fd109778b501357eca73079d86bed0916deede54e2e86eca2c04f3d0706e2a55ff84942cbfee22b5a92d309b84b8dd3decb9f3f2c4b24efb4f382833ffb867b5fe054b21d47db6c52ff52faa13ce2abdf7996e23a8c96bac48c02980d96234e478370027d55ba8752c17c7a1bf6253084654e79c13bacc51c1815c8b647e36cb" }; { a = SHA2_384; entropy_input = "f9e25060675e4c5734d818d9c31a0b232474520577e42f8c53f803aee2349f4a"; nonce = "9a62a41cf3f5a9e198dff8c907a35a3f"; personalization_string = ""; entropy_input_reseed = "888a7529909ae36053c75badb44d103118e171784a7b67dc0d7a4e1b1d44391a"; additional_input_reseed = "10a25d0027b1c55f615d3b7c3f235d791a81dfe8215315e0c38fccde27a5d8da"; additional_input_1 = "7b10e25044abd0917490e7f1a8cfd24966803fc9be260f3ab5bf954693f60885"; additional_input_2 = "a3563ec5c089fff127b2a2eaef12bd0cb3b18f3a0999754666113a052fd443f9"; returned_bits = "83b9fef4f31c71aebf3753d0404208678987fc4cb2d293a8ac8a547aed18a7a9e09d8196a07d6e97c909e64aef00d9b9530ca1cd69d65807857d9b30a74924a6be96dd96fc48ad5931892736a77f62f68c3fca75af3e2ea5b2a336f1e080a24fa28f81fd8b1a34d3c8aac650acaad25ed1e00bc44092a13940c821942add18bf0ed70c578c305711b0a4991ec5bddfaecee804619b197fd716aa2e6713c0cf91ea0a6d46a4d0ea80a7f70f4fc75307d342e69d1fdff989808b7500275cd05218" }; { a = SHA2_512; entropy_input = "58ebcec4539f4af1b32a854181dd0f512b8c704fa47537096a769eff28c59165"; nonce = "a18226cfc779efc9550f7be02006d83c"; personalization_string = ""; entropy_input_reseed = "230cd6e6909e301d1e99ecd1fff2b2cd00a56c7a684c8907bbb13ce3e9a0cbce"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "6f4e86f309f69144603961c5366e4f9b16d10c10593ea689a8e7435a327d2524f4468813ea7f3248d8d4bbe17b175cfc40617149983928b267dc0c4db46d2c17fe8bc0764386758af1a824e12eb897feafc1c7ef66f80ffcd993aa016e139991cde8435ee6bb0de45a7fb61eb1a6beb76e012b848ea003f687537e4bd00ced37efdda66333b53a8dd5220c281fbf68bfd9e72285e78197881efc540da4c1ba80a226013a2d7098d34af4112e7b8c865af15409f6901b952fee4a474e4027051e1dce879ddf5e84f3947dc9b94119d67e6b48ed6fd6b1f813c13d3ff30e121efce7918533925f50c8e381e87ea685f993619bacc9efc0aebc884b450646eeaa5e" }; { a = SHA2_512; entropy_input = "e1d2d72e7907e7214cb266f1ef641395e54b39e8365304661b0bee371f324652"; nonce = "8417ffd58420e48ec063de5df4462e39"; personalization_string = ""; entropy_input_reseed = "e6cae1b5f3a3a12faaaf39b98ee592c8d4f56b9d4534add5104b357d788c23ab"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "626a0863321ac75e0b6240ea6a619458634a978245c1533819c97114e63914009c9cab732f1310f60f64f033b00729424228671f33425099820ab108412d460f32c0015b73987e937b9bbdd29e5bfb8dbb6c95d2b69fccbc26b060cf0a5dc0992fb0e76b38bcd64fd7a726714e8c8542d44b2f9c5d2f2f8cb370b95e086b07e88f492f51fe6c288d78b76d0c3a6146c9dfce53e76cdbbd158d2944dd10197247004954d92f6b1df4badeb4bb1c98d7d3da2054e3300f6d8dda8863422e6a042c2d84b2bbed6be88f0704763410771b3786d2f6d968b6c224e0cf535e8d02c178b2e0b90e8a7fca0c431b7f3cf41b0a7c17778fe8c2eeb442c910ba88c7c364cd" }; { a = SHA2_512; entropy_input = "47c42df62b4dd570efd3c2722ad39a2df5f969a13f645fd27b5290877ba70916"; nonce = "c591934d4f66000ebf8c508fafc44f75"; personalization_string = "94822903cb5c2003c31c6d072ab0dda435add0de7d8f9d5f08b5cba410d888fd"; entropy_input_reseed = "d16a2c72c63580b9bcf156862214533a47b1686c871a0165604fdd00a412a484"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "f78e61b443b5a97b7e493a8ce35a43545290dd33d15ba4bf0ff78f34a25c46c4ff4cd485964cc96e90fe847d9fc9e42d96e4f5aaccf976a84e3e12100c28b0f7addb1c76f89663e11890f09e4beefe928a1e0b304f1d9dd0414cd115a01b641fd69c7071f2ca7c7f2e53560f4e91010ba11948195bc5deb556686feb0bb92fe61b3171e639ef47418f02be37796efdb6920952f3a8c766b52fccfa757e923e38028a84f9be1b802c1fbbbb4aef825f4c5e4fc1bf6e96f33ab90ea486710718c9e4f3247b2a55ccef5a5d342cac757f0b9f90bcdcc8c2ec3a43149bbd3924c85f0b5b7ae42151f4ded826ee6d47849ef4e8af64adf6863982503c23c4a0514ce0" }; { a = SHA2_512; entropy_input = "f840c75ce0cdb200a3bd980d6cedf1c7321e5f303cd0446c7afd2d2d66657447"; nonce = "b215333b15d55326bc9bebae6ae36efe"; personalization_string = "6d5ca4b1edf6c0afbdce02ecb30923b2f4f2b33121e21b2ffee964cc7de1abe8"; entropy_input_reseed = "a3a337c6fbeb6a979a4783f2b7f0f0dd6d3a9d3747de639a9047248a04a19f5b"; additional_input_reseed = "f56d2b1584ba2f129c77b29590c4e1dfdab5527b1791e3e445750ca6d4ae3542"; additional_input_1 = "05bd799249411b37b80590d49f3348631b06a2408a61635c70687003a8485302"; additional_input_2 = "12d26ac3b87924cda5d78a3e3c0bd81280e340723643ed1b2ebf2dfd52f5dc43"; returned_bits = "b48c13af7a9b6fa6385a7ee5d2ab97dcebf71a715dc465f413cb0962292df84c9c83c4093309f749359b0a0ddcc13162cb4ab8ff7b3a6336351ed79ebf47730f97accb6a960a9c5c25e0920a06cccc3b3f62b616c15ca18d7e0b5c2e7d8ad2518d1ef0bef515af866893e9378b56deec32825fe0a2c5a9729f658915b99ab22a03b7187e83d2d0f41b9467c8326f7bc87189dd8ade18b3a7edf0c0ea462dc22109ec91294cf8ce69c8cd0c129b423edadda8fbd25f4983a70d75001576a26405188bb0284975203694c318f3aa7fe47ec041bc4c11c9bceb1b131f74adcd72fc4d2813564de6d4711017800377be9e4c579e88464d67ea6e457a30f8f652375a" }; { a = SHA2_512; entropy_input = "46dfb4e82fc784ad0094dc81136834e5abc767fff2b876a06b1dbd2508dbed3a"; nonce = "64d40d3886ac152838f6853121fd68b7"; personalization_string = ""; entropy_input_reseed = "329004b8bb439305c4b2dcdd54ca97a4f54cb720a8582cdc03ac26f8a603f3fd"; additional_input_reseed = ""; additional_input_1 = ""; additional_input_2 = ""; returned_bits = "1887eb4c57b63109f7e446bf0a6c598de093a6013009503925d620f40cf98c8774a6c4a1affe57f8e6b190d0504ff4c4eb55ba4e8a2642d230ee845ed4e31d8adddb1a21dd45346cbda9884a322e6e8f38a82e888f81264a2e254ec2ad5ad4d60a162287e48bc39776eb57dce88cfe467b042d037d1b06877acc39f31b08b1aa13805fe0440a3506a7f59dc6e2376147acf87b78bbaef4c15b579335794688d142eedc231829a34a5c6976e0c8c4649edc178c8f7d8f9ae92f05e3d54df6e47cf9260a5a582a7d3b0030e9a5de912d0f7e4d3103233dcfa8dc0caeddf12a8502c7d941de883690d47bd1a1b61d723abaf0c31d67136fb427edcaa9526a9dc9fa" }; { a = SHA2_512; entropy_input = "12738c0ddd0c9ce0393d2acabdfa592286072a362e332ca3f8c401f01d610026"; nonce = "b983dcfd4af5e451f6efe155fcf3ec14"; personalization_string = ""; entropy_input_reseed = "07c8b69898caec3a1104e2e30b811ea095384cc636b9bd24e0f9837d3b8e0b4c"; additional_input_reseed = "fee06814eab6e55cb799e815d84f07278ec6c12d82dea12e261c5b72d0a4eaa5"; additional_input_1 = "f29287d46d517f090df11af46703d5de778028c787a3aa1e5904ed737b776912"; additional_input_2 = "0ce576cae56c46042ff27f9f11ed88f1ba534cf5f2581e5ad6bb69b642897886"; returned_bits = "6293103d028540484c262770ecf7c47c93e778daeda0a5d17a838a5933871af041ac603d81c4a8d73f4cacff06cee74424b57e8440e83939509ea1861adcaa29332bbce015c2b4d6c74154b52a6de9b4c5ec9edb4f54b7be42142b9be07bec5052b78bbc4bb742ee89f0399071f49a73df87b3fe762d1656346c9e8bf8e4b4b8b55e4e1ff23662b6586bf0f105e9d001f1593c175c9a234cbb17cfdafd90ba85f347cb79b0046fb5715bbf35f08345c8fbc26e4722425f04ba431c48ecffcacf15d09ea5abda92f541e46bb63e3933a2c053be4565275d34fa085baf555f92f446ba5e5d05fa0c63c53042092cb66c406d9b6b36b00e76d51b49b75c36e41e52" }; { a = SHA2_512; entropy_input = "6a2baf90d2e8b83355a0230a8fc7237c140f7699f40026e276deaefd4faa8e06"; nonce = "b2eecce638bd9fa485e9c9e0d94c3a78"; personalization_string = "a9ea2c4b2aba1f48f2c71ae1a7fee90e073912c833f2de9c5f802ac2ddc57fbd"; entropy_input_reseed = "820fc963827166de710208a7dc33936471e491fc21fb0119a252b49fefb28a01"; additional_input_reseed = "9a463484d172108807c43c048bd13a72d15b470c3443390774a55572d03f47b1"; additional_input_1 = "d98671978ae14b3531394a0785f78242d4b32eb61cffec6088efb8625693276a"; additional_input_2 = "b9aef32c40b7aa4fd732e4431bedce071e4f64405be1c85de03c7faa0aa7270f"; returned_bits = "f55791fdc9d763c34c0fc4cc457a438496f18f483cc60c493fcd0549812fad792f92381532548a8c2257c6e424fa570af260bd47de92f248f57291fead3a68c94be9dc12a656630622be9b602d4fc5037c29bbb5fa92fed2235186048f652131f845f01ed718baf05957e863239e94a5613aa47dd25d5bc9f170e4047e86ef1eefa60e359f2204a3f453c9b37dcfd9410736ee14e296abcdc185f3ed31d8ad461a81479f957e69c34334a24e22f4a69606db8bca6cb189e7de4b83d8a10461fba1942c83aa2e5f84dced9440f10a54c74153643287313ae7fe1bf23c6abecc55c4a3f5540495b7d29a302d426ee2f13dd9ed7a5a6618724544da63527c702e4c" }; { a = SHA2_512; entropy_input = "47139f544af9f6b0b8022bbae5b936a3f4bf8a0f1cd10c8c5fb8bb7363df6411"; nonce = "b99640f70c7b55605f7bee6753f30675"; personalization_string = "0f88357519e8f2c05495c595056e6023460bea47e79f72b113784eb6a77f9f28"; entropy_input_reseed = "83ed7fb5ae85138161fe90b14b15295b11d81b0ecbd9f1838a2858cf9e822886"; additional_input_reseed = "e973ea2d399b9c4ad685411a619b7a5ce6f6568bc66efb8855a69f256829a62d"; additional_input_1 = "1bd8090104b78844f6d615e93b7ae0c921517c97735c0aaa28cdee1eb0a14659"; additional_input_2 = "4d57d04fc0a2adc6ebb618f1236fee0eb00e38ff82137f5e375be00ad1aac35e"; returned_bits = "8c4ce3292ae500557b40e4215665c8db5ccba13fbd2d26ca8d1fdad9dca158371ec0003cf801fd28741a2fd31d15e4c0612c68e19fa4e19c626ce4b0184303f4544c414a6541c7d4ac5e6555d22e21c09a096aa9ec09c902eb67a2de9eba94b719ec1ba4dd5dbafee93fcd5125223eaae0bf0d8e7eb92ea0610cc32b69584c0a1565802028f31e6910021d618e5138137eccab894a5385ca4544fdf20919ef2216a3eaf44fdacc7fe05ce22e565a5ab013cd6c9e0a80b430fa8b72127f84f3a780d4ee92c72901eafc8a21c56dcc687ac4ce464cce068895471b36f7b58987ae3272581f00f8d667085bdeadcb06ffef5b1b329bf1db71ce101a2d694de9e322" }; { a = SHA2_512; entropy_input = "2886ff4e11950c1e639398b2c7d6908d5c2e4daeb7719e6dd98a39b1428ea7df"; nonce = "8cbb97f58cf243045bdadb2f9bbdab10"; personalization_string = ""; entropy_input_reseed = "f487b94b5e4eda49e933e0c268eb5042c422df88061ebffd893d39fafd58efd3"; additional_input_reseed = "ff8e7656a21bcced082972719ebf87539c4825cb0f4beabd12a12d544dea87af"; additional_input_1 = "f64dd3b0efc5c8c146f9b9b8f0ec7ccb784e87c16268a4aab31e9eddf2c9b83e"; additional_input_2 = "9dc16b955ae805f10ebbdc3794a2abe671a339ca148b46ef6ea208698a54a0d8"; returned_bits = "0e8c9cb99fec37602b291e508e43c2ab323d05764184379ca3a2ca4080ed26c2dbfdf3d1916485c7eba49077ca881fb03d07f967cad9b477959f007a6188150b6630218af55fdd7be2eb88d48b5ec6b6876ec25665c0310624283d2b5460e3736f8b9f0b84095aa4754ac59067a7cc73402c09b1768972b3abd49e0e237a741649ea7888ea4a024c0952b94af27c53b13afcaa4fb7976f65443809d1bbd7e4b741bcd6c4a3f2cdf863e719e5d5e60043e771ce5355dee1c5299ddfa54d77ddde2924271c0ece1e1e1e8aa6218c08aee40993eed58959af430c7d53b4179aa355febcc40124cb7a1d2965e36832e5f42f9a48275888725cba28d72398fbefac94" }; { a = SHA2_512; entropy_input = "2886ff4e11950c1e639398b2c7d6908d5c2e4daeb7719e6dd98a39b1428ea7df"; nonce = "8cbb97f58cf243045bdadb2f9bbdab10"; personalization_string = ""; entropy_input_reseed = "f487b94b5e4eda49e933e0c268eb5042c422df88061ebffd893d39fafd58efd3"; additional_input_reseed = "ff8e7656a21bcced082972719ebf87539c4825cb0f4beabd12a12d544dea87af"; additional_input_1 = "f64dd3b0efc5c8c146f9b9b8f0ec7ccb784e87c16268a4aab31e9eddf2c9b83e"; additional_input_2 = "9dc16b955ae805f10ebbdc3794a2abe671a339ca148b46ef6ea208698a54a0d8"; returned_bits = "0e8c9cb99fec37602b291e508e43c2ab323d05764184379ca3a2ca4080ed26c2dbfdf3d1916485c7eba49077ca881fb03d07f967cad9b477959f007a6188150b6630218af55fdd7be2eb88d48b5ec6b6876ec25665c0310624283d2b5460e3736f8b9f0b84095aa4754ac59067a7cc73402c09b1768972b3abd49e0e237a741649ea7888ea4a024c0952b94af27c53b13afcaa4fb7976f65443809d1bbd7e4b741bcd6c4a3f2cdf863e719e5d5e60043e771ce5355dee1c5299ddfa54d77ddde2924271c0ece1e1e1e8aa6218c08aee40993eed58959af430c7d53b4179aa355febcc40124cb7a1d2965e36832e5f42f9a48275888725cba28d72398fbefac" } ]
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.scale64_10
val scale64_10 : Type0
let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\ x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256}
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 86, "end_line": 42, "start_col": 0, "start_line": 40 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) let scale64 = s:nat{s <= 256} let nat5 = (nat & nat & nat & nat & nat) let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256}
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.BignumQ.Definitions.nat10", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
true
true
let scale64_10 =
x: nat10 { let x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\ x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256 }
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_mul1_lshift_add
val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res))
val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res))
let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j)
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 119, "start_col": 0, "start_line": 114 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
aLen: Lib.IntTypes.size_t -> a: Hacl.Bignum.Definitions.lbignum t aLen -> b_j: Hacl.Bignum.Definitions.limb t -> resLen: Lib.IntTypes.size_t -> j: Lib.IntTypes.size_t{Lib.IntTypes.v j + Lib.IntTypes.v aLen <= Lib.IntTypes.v resLen} -> res: Hacl.Bignum.Definitions.lbignum t resLen -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Lib.update_sub_f_carry", "Hacl.Spec.Bignum.Definitions.limb", "FStar.Monotonic.HyperStack.mem", "Hacl.Spec.Bignum.Multiplication.bn_mul1_add_in_place", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.lseq", "Prims.unit", "Hacl.Bignum.Multiplication.bn_mul1_add_in_place", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.Buffer.sub" ]
[]
false
true
false
false
false
let bn_mul1_lshift_add #t aLen a b_j resLen j res =
let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j)
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test2_len
val test2_len : Prims.int
let test2_len = 82
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 126, "start_col": 0, "start_line": 126 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2 let test2_hash = Spec.Hash.Definitions.SHA2_256 let test2_ikm : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_salt : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x60uy; 0x61uy; 0x62uy; 0x63uy; 0x64uy; 0x65uy; 0x66uy; 0x67uy; 0x68uy; 0x69uy; 0x6auy; 0x6buy; 0x6cuy; 0x6duy; 0x6euy; 0x6fuy; 0x70uy; 0x71uy; 0x72uy; 0x73uy; 0x74uy; 0x75uy; 0x76uy; 0x77uy; 0x78uy; 0x79uy; 0x7auy; 0x7buy; 0x7cuy; 0x7duy; 0x7euy; 0x7fuy; 0x80uy; 0x81uy; 0x82uy; 0x83uy; 0x84uy; 0x85uy; 0x86uy; 0x87uy; 0x88uy; 0x89uy; 0x8auy; 0x8buy; 0x8cuy; 0x8duy; 0x8euy; 0x8fuy; 0x90uy; 0x91uy; 0x92uy; 0x93uy; 0x94uy; 0x95uy; 0x96uy; 0x97uy; 0x98uy; 0x99uy; 0x9auy; 0x9buy; 0x9cuy; 0x9duy; 0x9euy; 0x9fuy; 0xa0uy; 0xa1uy; 0xa2uy; 0xa3uy; 0xa4uy; 0xa5uy; 0xa6uy; 0xa7uy; 0xa8uy; 0xa9uy; 0xaauy; 0xabuy; 0xacuy; 0xaduy; 0xaeuy; 0xafuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_info : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0xb0uy; 0xb1uy; 0xb2uy; 0xb3uy; 0xb4uy; 0xb5uy; 0xb6uy; 0xb7uy; 0xb8uy; 0xb9uy; 0xbauy; 0xbbuy; 0xbcuy; 0xbduy; 0xbeuy; 0xbfuy; 0xc0uy; 0xc1uy; 0xc2uy; 0xc3uy; 0xc4uy; 0xc5uy; 0xc6uy; 0xc7uy; 0xc8uy; 0xc9uy; 0xcauy; 0xcbuy; 0xccuy; 0xcduy; 0xceuy; 0xcfuy; 0xd0uy; 0xd1uy; 0xd2uy; 0xd3uy; 0xd4uy; 0xd5uy; 0xd6uy; 0xd7uy; 0xd8uy; 0xd9uy; 0xdauy; 0xdbuy; 0xdcuy; 0xdduy; 0xdeuy; 0xdfuy; 0xe0uy; 0xe1uy; 0xe2uy; 0xe3uy; 0xe4uy; 0xe5uy; 0xe6uy; 0xe7uy; 0xe8uy; 0xe9uy; 0xeauy; 0xebuy; 0xecuy; 0xeduy; 0xeeuy; 0xefuy; 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy; 0xfauy; 0xfbuy; 0xfcuy; 0xfduy; 0xfeuy; 0xffuy ] in assert_norm (List.Tot.length l == 80); of_list l
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.int
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let test2_len =
82
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_mul_st
val bn_mul_st : t: Hacl.Bignum.Definitions.limb_t -> Type0
let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 134, "start_col": 0, "start_line": 123 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.max_size_t", "Lib.IntTypes.op_Plus_Bang", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Lib.Buffer.eq_or_disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Hacl.Spec.Bignum.Definitions.limb", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Multiplication.bn_mul" ]
[]
false
false
false
true
true
let bn_mul_st (t: limb_t) =
aLen: size_t -> a: lbignum t aLen -> bLen: size_t{v aLen + v bLen <= max_size_t} -> b: lbignum t bLen -> res: lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test3_len
val test3_len : Prims.int
let test3_len = 42
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 182, "start_col": 0, "start_line": 182 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2 let test2_hash = Spec.Hash.Definitions.SHA2_256 let test2_ikm : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_salt : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x60uy; 0x61uy; 0x62uy; 0x63uy; 0x64uy; 0x65uy; 0x66uy; 0x67uy; 0x68uy; 0x69uy; 0x6auy; 0x6buy; 0x6cuy; 0x6duy; 0x6euy; 0x6fuy; 0x70uy; 0x71uy; 0x72uy; 0x73uy; 0x74uy; 0x75uy; 0x76uy; 0x77uy; 0x78uy; 0x79uy; 0x7auy; 0x7buy; 0x7cuy; 0x7duy; 0x7euy; 0x7fuy; 0x80uy; 0x81uy; 0x82uy; 0x83uy; 0x84uy; 0x85uy; 0x86uy; 0x87uy; 0x88uy; 0x89uy; 0x8auy; 0x8buy; 0x8cuy; 0x8duy; 0x8euy; 0x8fuy; 0x90uy; 0x91uy; 0x92uy; 0x93uy; 0x94uy; 0x95uy; 0x96uy; 0x97uy; 0x98uy; 0x99uy; 0x9auy; 0x9buy; 0x9cuy; 0x9duy; 0x9euy; 0x9fuy; 0xa0uy; 0xa1uy; 0xa2uy; 0xa3uy; 0xa4uy; 0xa5uy; 0xa6uy; 0xa7uy; 0xa8uy; 0xa9uy; 0xaauy; 0xabuy; 0xacuy; 0xaduy; 0xaeuy; 0xafuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_info : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0xb0uy; 0xb1uy; 0xb2uy; 0xb3uy; 0xb4uy; 0xb5uy; 0xb6uy; 0xb7uy; 0xb8uy; 0xb9uy; 0xbauy; 0xbbuy; 0xbcuy; 0xbduy; 0xbeuy; 0xbfuy; 0xc0uy; 0xc1uy; 0xc2uy; 0xc3uy; 0xc4uy; 0xc5uy; 0xc6uy; 0xc7uy; 0xc8uy; 0xc9uy; 0xcauy; 0xcbuy; 0xccuy; 0xcduy; 0xceuy; 0xcfuy; 0xd0uy; 0xd1uy; 0xd2uy; 0xd3uy; 0xd4uy; 0xd5uy; 0xd6uy; 0xd7uy; 0xd8uy; 0xd9uy; 0xdauy; 0xdbuy; 0xdcuy; 0xdduy; 0xdeuy; 0xdfuy; 0xe0uy; 0xe1uy; 0xe2uy; 0xe3uy; 0xe4uy; 0xe5uy; 0xe6uy; 0xe7uy; 0xe8uy; 0xe9uy; 0xeauy; 0xebuy; 0xecuy; 0xeduy; 0xeeuy; 0xefuy; 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy; 0xfauy; 0xfbuy; 0xfcuy; 0xfduy; 0xfeuy; 0xffuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_len = 82 let test2_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x06uy; 0xa6uy; 0xb8uy; 0x8cuy; 0x58uy; 0x53uy; 0x36uy; 0x1auy; 0x06uy; 0x10uy; 0x4cuy; 0x9cuy; 0xebuy; 0x35uy; 0xb4uy; 0x5cuy; 0xefuy; 0x76uy; 0x00uy; 0x14uy; 0x90uy; 0x46uy; 0x71uy; 0x01uy; 0x4auy; 0x19uy; 0x3fuy; 0x40uy; 0xc1uy; 0x5fuy; 0xc2uy; 0x44uy ] in assert_norm (List.Tot.length l == 32); of_list l let test2_expected_okm : lbytes 82 = let l = List.Tot.map u8_from_UInt8 [ 0xb1uy; 0x1euy; 0x39uy; 0x8duy; 0xc8uy; 0x03uy; 0x27uy; 0xa1uy; 0xc8uy; 0xe7uy; 0xf7uy; 0x8cuy; 0x59uy; 0x6auy; 0x49uy; 0x34uy; 0x4fuy; 0x01uy; 0x2euy; 0xdauy; 0x2duy; 0x4euy; 0xfauy; 0xd8uy; 0xa0uy; 0x50uy; 0xccuy; 0x4cuy; 0x19uy; 0xafuy; 0xa9uy; 0x7cuy; 0x59uy; 0x04uy; 0x5auy; 0x99uy; 0xcauy; 0xc7uy; 0x82uy; 0x72uy; 0x71uy; 0xcbuy; 0x41uy; 0xc6uy; 0x5euy; 0x59uy; 0x0euy; 0x09uy; 0xdauy; 0x32uy; 0x75uy; 0x60uy; 0x0cuy; 0x2fuy; 0x09uy; 0xb8uy; 0x36uy; 0x77uy; 0x93uy; 0xa9uy; 0xacuy; 0xa3uy; 0xdbuy; 0x71uy; 0xccuy; 0x30uy; 0xc5uy; 0x81uy; 0x79uy; 0xecuy; 0x3euy; 0x87uy; 0xc1uy; 0x4cuy; 0x01uy; 0xd5uy; 0xc1uy; 0xf3uy; 0x43uy; 0x4fuy; 0x1duy; 0x87uy ] in assert_norm (List.Tot.length l == 82); of_list l /// Test 3 let test3_hash = Spec.Hash.Definitions.SHA2_256 let test3_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test3_salt : lbytes 0 = let l = List.Tot.map u8_from_UInt8 [] in assert_norm (List.Tot.length l == 0); of_list l let test3_info : lbytes 0 = let l = List.Tot.map u8_from_UInt8 [] in assert_norm (List.Tot.length l == 0); of_list l
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.int
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let test3_len =
42
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.scale64_5
val scale64_5 : Type0
let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256}
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 38, "start_col": 0, "start_line": 37 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) let scale64 = s:nat{s <= 256} let nat5 = (nat & nat & nat & nat & nat) let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.BignumQ.Definitions.nat5", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
true
true
let scale64_5 =
x: nat5 { let x1, x2, x3, x4, x5 = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 }
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.scale64
val scale64 : Type0
let scale64 = s:nat{s <= 256}
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 33, "start_col": 0, "start_line": 33 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual" ]
[]
false
false
false
true
true
let scale64 =
s: nat{s <= 256}
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_sqr_st
val bn_sqr_st : t: Hacl.Bignum.Definitions.limb_t -> Type0
let bn_sqr_st (t:limb_t) = aLen:size_t{0 < v aLen /\ v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr (as_seq h0 a))
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 204, "start_col": 0, "start_line": 197 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j) inline_for_extraction noextract let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) inline_for_extraction noextract val bn_mul: #t:limb_t -> bn_mul_st t let bn_mul #t aLen a bLen b res = [@inline_let] let resLen = aLen +! bLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@ inline_let] let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in loop1 h0 bLen res spec (fun j -> Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j); let bj = b.(j) in res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res ) [@CInline] let bn_mul_u32 : bn_mul_st U32 = bn_mul [@CInline] let bn_mul_u64 : bn_mul_st U64 = bn_mul inline_for_extraction noextract let bn_mul_u (#t:limb_t) : bn_mul_st t = match t with | U32 -> bn_mul_u32 | U64 -> bn_mul_u64 inline_for_extraction noextract val bn_sqr_diag: #t:limb_t -> aLen:size_t{v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a /\ as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a)) let bn_sqr_diag #t aLen a res = let h0 = ST.get () in [@inline_let] let spec h = SS.bn_sqr_diag_f (as_seq h a) in loop1 h0 aLen res spec (fun i -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i); let (hi, lo) = mul_wide a.(i) a.(i) in res.(2ul *! i) <- lo; res.(2ul *! i +! 1ul) <- hi) // This code is taken from BoringSSL // https://github.com/google/boringssl/blob/master/crypto/fipsmodule/bn/mul.c#L551
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Hacl.Spec.Bignum.Definitions.limb", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Squaring.bn_sqr" ]
[]
false
false
false
true
true
let bn_sqr_st (t: limb_t) =
aLen: size_t{0 < v aLen /\ v aLen + v aLen <= max_size_t} -> a: lbignum t aLen -> res: lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr (as_seq h0 a))
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test1_ikm
val test1_ikm:lbytes 22
val test1_ikm:lbytes 22
let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 26, "start_col": 0, "start_line": 19 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 22
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_ikm:lbytes 22 =
let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.qelem_fits1
val qelem_fits1 : x: Lib.IntTypes.uint64 -> m: Hacl.Spec.BignumQ.Definitions.scale64 -> Prims.bool
let qelem_fits1 (x:uint64) (m:scale64) = uint_v x <= m * max56
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 49, "start_col": 0, "start_line": 48 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) let scale64 = s:nat{s <= 256} let nat5 = (nat & nat & nat & nat & nat) let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256} let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\ x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256} inline_for_extraction noextract let max56 = pow56 - 1
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Lib.IntTypes.uint64 -> m: Hacl.Spec.BignumQ.Definitions.scale64 -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint64", "Hacl.Spec.BignumQ.Definitions.scale64", "Prims.op_LessThanOrEqual", "Lib.IntTypes.uint_v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.BignumQ.Definitions.max56", "Prims.bool" ]
[]
false
false
false
true
false
let qelem_fits1 (x: uint64) (m: scale64) =
uint_v x <= m * max56
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.qelem_wide_fits5
val qelem_wide_fits5 : f: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> m: Hacl.Spec.BignumQ.Definitions.scale64_10 -> Prims.logical
let qelem_wide_fits5 (f:qelem_wide5) (m:scale64_10) = let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = f in let (m1,m2,m3,m4,m5,m6,m7,m8,m9,m10) = m in qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\ qelem_fits1 x5 m5 /\ qelem_fits1 x6 m6 /\ qelem_fits1 x7 m7 /\ qelem_fits1 x8 m8 /\ qelem_fits1 x9 m9 /\ qelem_fits1 x10 m10
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 74, "start_col": 0, "start_line": 62 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) let scale64 = s:nat{s <= 256} let nat5 = (nat & nat & nat & nat & nat) let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256} let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\ x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256} inline_for_extraction noextract let max56 = pow56 - 1 let qelem_fits1 (x:uint64) (m:scale64) = uint_v x <= m * max56 let qelem_fits5 (f:qelem5) (m:scale64_5) = let (x1,x2,x3,x4,x5) = f in let (m1,m2,m3,m4,m5) = m in qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\ qelem_fits1 x5 m5
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> m: Hacl.Spec.BignumQ.Definitions.scale64_10 -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Hacl.Spec.BignumQ.Definitions.scale64_10", "Lib.IntTypes.uint64", "Prims.nat", "Prims.l_and", "Prims.b2t", "Hacl.Spec.BignumQ.Definitions.qelem_fits1", "Prims.logical" ]
[]
false
false
false
true
true
let qelem_wide_fits5 (f: qelem_wide5) (m: scale64_10) =
let x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 = f in let m1, m2, m3, m4, m5, m6, m7, m8, m9, m10 = m in qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\ qelem_fits1 x5 m5 /\ qelem_fits1 x6 m6 /\ qelem_fits1 x7 m7 /\ qelem_fits1 x8 m8 /\ qelem_fits1 x9 m9 /\ qelem_fits1 x10 m10
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.qelem_fits5
val qelem_fits5 : f: Hacl.Spec.BignumQ.Definitions.qelem5 -> m: Hacl.Spec.BignumQ.Definitions.scale64_5 -> Prims.logical
let qelem_fits5 (f:qelem5) (m:scale64_5) = let (x1,x2,x3,x4,x5) = f in let (m1,m2,m3,m4,m5) = m in qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\ qelem_fits1 x5 m5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 59, "start_col": 0, "start_line": 52 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) let scale64 = s:nat{s <= 256} let nat5 = (nat & nat & nat & nat & nat) let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256} let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\ x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256} inline_for_extraction noextract let max56 = pow56 - 1 let qelem_fits1 (x:uint64) (m:scale64) = uint_v x <= m * max56
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.Spec.BignumQ.Definitions.qelem5 -> m: Hacl.Spec.BignumQ.Definitions.scale64_5 -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "Hacl.Spec.BignumQ.Definitions.scale64_5", "Lib.IntTypes.uint64", "Prims.nat", "Prims.l_and", "Prims.b2t", "Hacl.Spec.BignumQ.Definitions.qelem_fits1", "Prims.logical" ]
[]
false
false
false
true
true
let qelem_fits5 (f: qelem5) (m: scale64_5) =
let x1, x2, x3, x4, x5 = f in let m1, m2, m3, m4, m5 = m in qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\ qelem_fits1 x5 m5
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test1_info
val test1_info:lbytes 10
val test1_info:lbytes 10
let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 44, "start_col": 0, "start_line": 38 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 10
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_info:lbytes 10 =
let l = List.Tot.map u8_from_UInt8 [0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy] in assert_norm (List.Tot.length l == 10); of_list l
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.as_nat5
val as_nat5: f:qelem5 -> GTot nat
val as_nat5: f:qelem5 -> GTot nat
let as_nat5 f = let (s0, s1, s2, s3, s4) = f in v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 69, "end_line": 81, "start_col": 0, "start_line": 79 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) let scale64 = s:nat{s <= 256} let nat5 = (nat & nat & nat & nat & nat) let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256} let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\ x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256} inline_for_extraction noextract let max56 = pow56 - 1 let qelem_fits1 (x:uint64) (m:scale64) = uint_v x <= m * max56 let qelem_fits5 (f:qelem5) (m:scale64_5) = let (x1,x2,x3,x4,x5) = f in let (m1,m2,m3,m4,m5) = m in qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\ qelem_fits1 x5 m5 let qelem_wide_fits5 (f:qelem_wide5) (m:scale64_10) = let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = f in let (m1,m2,m3,m4,m5,m6,m7,m8,m9,m10) = m in qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\ qelem_fits1 x5 m5 /\ qelem_fits1 x6 m6 /\ qelem_fits1 x7 m7 /\ qelem_fits1 x8 m8 /\ qelem_fits1 x9 m9 /\ qelem_fits1 x10 m10 noextract
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.Spec.BignumQ.Definitions.qelem5 -> Prims.GTot Prims.nat
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "Lib.IntTypes.uint64", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.BignumQ.Definitions.pow56", "Hacl.Spec.BignumQ.Definitions.pow112", "Hacl.Spec.BignumQ.Definitions.pow168", "Hacl.Spec.BignumQ.Definitions.pow224", "Prims.nat" ]
[]
false
false
false
false
false
let as_nat5 f =
let s0, s1, s2, s3, s4 = f in v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224
false
Hacl.Impl.K256.PointMul.fst
Hacl.Impl.K256.PointMul.point_mul_g_double_vartime
val point_mul_g_double_vartime: out:point -> scalar1:qelem -> scalar2:qelem -> q2:point -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h scalar2 /\ live h q2 /\ disjoint q2 out /\ disjoint out scalar1 /\ disjoint out scalar2 /\ point_inv h q2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
val point_mul_g_double_vartime: out:point -> scalar1:qelem -> scalar2:qelem -> q2:point -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h scalar2 /\ live h q2 /\ disjoint q2 out /\ disjoint out scalar1 /\ disjoint out scalar2 /\ point_inv h q2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
let point_mul_g_double_vartime out scalar1 scalar2 q2 = push_frame (); [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let table_len = 32ul in assert_norm (pow2 5 == v table_len); let q1 = create 15ul (u64 0) in make_g q1; let table2 = create (table_len *! len) (u64 0) in PT.lprecomp_table len ctx_len k (null uint64) q2 table_len table2; let h = ST.get () in assert (table_inv_w5 (as_seq h q2) (as_seq h table2)); point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2; pop_frame ()
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 250, "start_col": 0, "start_line": 234 }
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) //SPT256.exp_as_exp_four_nat256_precomp S.mk_k256_comm_monoid //(S.to_aff_point (point_eval h0 q1)) (qas_nat h0 scalar)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b = let cm = S.mk_k256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_k256_concrete_ops S.g 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b)) [@CInline] let point_mul_g out scalar = push_frame (); let h0 = ST.get () in let q1 = create 15ul (u64 0) in make_g q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc out scalar q1 q2 q3 q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame () //------------------------- inline_for_extraction noextract val point_mul_g_double_vartime_noalloc: out:point -> scalar1:qelem -> q1:point -> scalar2:qelem -> q2:point -> table2:lbuffer uint64 (32ul *! 15ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q /\ point_inv h q1 /\ point_eval h q1 == S.g /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2))) let point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in [@inline_let] let bLen = 4ul in [@inline_let] let bBits = 256ul in assert_norm (pow2 (v l) == v table_len); let h0 = ST.get () in recall_contents precomp_basepoint_table_w5 precomp_basepoint_table_lseq_w5; let h1 = ST.get () in precomp_basepoint_table_lemma_w5 (); assert (table_inv_w5 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w5)); assert (table_inv_w5 (as_seq h1 q2) (as_seq h1 table2)); ME.mk_lexp_double_fw_tables len ctx_len k l table_len table_inv_w5 table_inv_w5 (BE.lprecomp_get_vartime len ctx_len k l table_len) (BE.lprecomp_get_vartime len ctx_len k l table_len) (null uint64) q1 bLen bBits scalar1 q2 scalar2 (to_const precomp_basepoint_table_w5) (to_const table2) out; SE.exp_double_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q1) 256 (qas_nat h0 scalar1) (point_eval h0 q2) (qas_nat h0 scalar2) 5
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "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.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.Impl.K256.Point.point -> scalar1: Hacl.K256.Scalar.qelem -> scalar2: Hacl.K256.Scalar.qelem -> q2: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.K256.PointMul.point_mul_g_double_vartime_noalloc", "Prims._assert", "Hacl.Impl.K256.PointMul.table_inv_w5", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.PrecompTable.lprecomp_table", "Lib.Buffer.null", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.mul", "Lib.Buffer.create", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "Hacl.Impl.K256.Point.make_g", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Prims.pow2", "Lib.IntTypes.v", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.K256.Group.mk_k256_concrete_ops", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let point_mul_g_double_vartime out scalar1 scalar2 q2 =
push_frame (); [@@ inline_let ]let len = 15ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_k256_concrete_ops in [@@ inline_let ]let table_len = 32ul in assert_norm (pow2 5 == v table_len); let q1 = create 15ul (u64 0) in make_g q1; let table2 = create (table_len *! len) (u64 0) in PT.lprecomp_table len ctx_len k (null uint64) q2 table_len table2; let h = ST.get () in assert (table_inv_w5 (as_seq h q2) (as_seq h table2)); point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2; pop_frame ()
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_mul1
val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 60, "start_col": 0, "start_line": 37 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
aLen: Lib.IntTypes.size_t -> a: Hacl.Bignum.Definitions.lbignum t aLen -> l: Hacl.Bignum.Definitions.limb t -> res: Hacl.Bignum.Definitions.lbignum t aLen -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Lib.fill_elems4", "Hacl.Spec.Bignum.Definitions.limb", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Lib.lemma_eq_disjoint", "Lib.Buffer.op_Array_Assignment", "Hacl.Bignum.Base.mul_wide_add_st", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Multiplication.bn_mul1_f", "Lib.Buffer.as_seq", "LowStar.Monotonic.Buffer.loc", "Prims.l_and", "LowStar.Monotonic.Buffer.loc_disjoint", "Lib.Buffer.loc", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "Lib.IntTypes.size_nat", "Prims.eq2", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let bn_mul1 #t aLen a l res =
push_frame (); let c = create 1ul (uint #t 0) in [@@ inline_let ]let refl h i = LSeq.index (as_seq h c) 0 in [@@ inline_let ]let footprint (i: size_nat{i <= v aLen}) : GTot (l: B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@@ inline_let ]let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1); let c = c.(0ul) in pop_frame (); c
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test3_info
val test3_info:lbytes 0
val test3_info:lbytes 0
let test3_info : lbytes 0 = let l = List.Tot.map u8_from_UInt8 [] in assert_norm (List.Tot.length l == 0); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 180, "start_col": 0, "start_line": 177 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2 let test2_hash = Spec.Hash.Definitions.SHA2_256 let test2_ikm : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_salt : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x60uy; 0x61uy; 0x62uy; 0x63uy; 0x64uy; 0x65uy; 0x66uy; 0x67uy; 0x68uy; 0x69uy; 0x6auy; 0x6buy; 0x6cuy; 0x6duy; 0x6euy; 0x6fuy; 0x70uy; 0x71uy; 0x72uy; 0x73uy; 0x74uy; 0x75uy; 0x76uy; 0x77uy; 0x78uy; 0x79uy; 0x7auy; 0x7buy; 0x7cuy; 0x7duy; 0x7euy; 0x7fuy; 0x80uy; 0x81uy; 0x82uy; 0x83uy; 0x84uy; 0x85uy; 0x86uy; 0x87uy; 0x88uy; 0x89uy; 0x8auy; 0x8buy; 0x8cuy; 0x8duy; 0x8euy; 0x8fuy; 0x90uy; 0x91uy; 0x92uy; 0x93uy; 0x94uy; 0x95uy; 0x96uy; 0x97uy; 0x98uy; 0x99uy; 0x9auy; 0x9buy; 0x9cuy; 0x9duy; 0x9euy; 0x9fuy; 0xa0uy; 0xa1uy; 0xa2uy; 0xa3uy; 0xa4uy; 0xa5uy; 0xa6uy; 0xa7uy; 0xa8uy; 0xa9uy; 0xaauy; 0xabuy; 0xacuy; 0xaduy; 0xaeuy; 0xafuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_info : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0xb0uy; 0xb1uy; 0xb2uy; 0xb3uy; 0xb4uy; 0xb5uy; 0xb6uy; 0xb7uy; 0xb8uy; 0xb9uy; 0xbauy; 0xbbuy; 0xbcuy; 0xbduy; 0xbeuy; 0xbfuy; 0xc0uy; 0xc1uy; 0xc2uy; 0xc3uy; 0xc4uy; 0xc5uy; 0xc6uy; 0xc7uy; 0xc8uy; 0xc9uy; 0xcauy; 0xcbuy; 0xccuy; 0xcduy; 0xceuy; 0xcfuy; 0xd0uy; 0xd1uy; 0xd2uy; 0xd3uy; 0xd4uy; 0xd5uy; 0xd6uy; 0xd7uy; 0xd8uy; 0xd9uy; 0xdauy; 0xdbuy; 0xdcuy; 0xdduy; 0xdeuy; 0xdfuy; 0xe0uy; 0xe1uy; 0xe2uy; 0xe3uy; 0xe4uy; 0xe5uy; 0xe6uy; 0xe7uy; 0xe8uy; 0xe9uy; 0xeauy; 0xebuy; 0xecuy; 0xeduy; 0xeeuy; 0xefuy; 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy; 0xfauy; 0xfbuy; 0xfcuy; 0xfduy; 0xfeuy; 0xffuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_len = 82 let test2_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x06uy; 0xa6uy; 0xb8uy; 0x8cuy; 0x58uy; 0x53uy; 0x36uy; 0x1auy; 0x06uy; 0x10uy; 0x4cuy; 0x9cuy; 0xebuy; 0x35uy; 0xb4uy; 0x5cuy; 0xefuy; 0x76uy; 0x00uy; 0x14uy; 0x90uy; 0x46uy; 0x71uy; 0x01uy; 0x4auy; 0x19uy; 0x3fuy; 0x40uy; 0xc1uy; 0x5fuy; 0xc2uy; 0x44uy ] in assert_norm (List.Tot.length l == 32); of_list l let test2_expected_okm : lbytes 82 = let l = List.Tot.map u8_from_UInt8 [ 0xb1uy; 0x1euy; 0x39uy; 0x8duy; 0xc8uy; 0x03uy; 0x27uy; 0xa1uy; 0xc8uy; 0xe7uy; 0xf7uy; 0x8cuy; 0x59uy; 0x6auy; 0x49uy; 0x34uy; 0x4fuy; 0x01uy; 0x2euy; 0xdauy; 0x2duy; 0x4euy; 0xfauy; 0xd8uy; 0xa0uy; 0x50uy; 0xccuy; 0x4cuy; 0x19uy; 0xafuy; 0xa9uy; 0x7cuy; 0x59uy; 0x04uy; 0x5auy; 0x99uy; 0xcauy; 0xc7uy; 0x82uy; 0x72uy; 0x71uy; 0xcbuy; 0x41uy; 0xc6uy; 0x5euy; 0x59uy; 0x0euy; 0x09uy; 0xdauy; 0x32uy; 0x75uy; 0x60uy; 0x0cuy; 0x2fuy; 0x09uy; 0xb8uy; 0x36uy; 0x77uy; 0x93uy; 0xa9uy; 0xacuy; 0xa3uy; 0xdbuy; 0x71uy; 0xccuy; 0x30uy; 0xc5uy; 0x81uy; 0x79uy; 0xecuy; 0x3euy; 0x87uy; 0xc1uy; 0x4cuy; 0x01uy; 0xd5uy; 0xc1uy; 0xf3uy; 0x43uy; 0x4fuy; 0x1duy; 0x87uy ] in assert_norm (List.Tot.length l == 82); of_list l /// Test 3 let test3_hash = Spec.Hash.Definitions.SHA2_256 let test3_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test3_salt : lbytes 0 = let l = List.Tot.map u8_from_UInt8 [] in assert_norm (List.Tot.length l == 0); of_list l
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 0
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Nil" ]
[]
false
false
false
false
false
let test3_info:lbytes 0 =
let l = List.Tot.map u8_from_UInt8 [] in assert_norm (List.Tot.length l == 0); of_list l
false
Hacl.Spec.BignumQ.Definitions.fst
Hacl.Spec.BignumQ.Definitions.wide_as_nat5
val wide_as_nat5: f:qelem_wide5 -> GTot nat
val wide_as_nat5: f:qelem_wide5 -> GTot nat
let wide_as_nat5 f = let (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) = f in v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224 + v s5 * pow280 + v s6 * pow336 + v s7 * pow392 + v s8 * pow448 + v s9 * pow504
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 79, "end_line": 89, "start_col": 0, "start_line": 86 }
module Hacl.Spec.BignumQ.Definitions open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) //abstract let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = let pow56: pos = normalize_term (pow2 56) in assert_norm (pow56 > 0); assert_norm (pow56 == pow2 56); assert_norm (pow2 64 == 256 * pow56); assert_norm (pow2 128 == 65536 * pow56 * pow56); pow56 let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) let scale64 = s:nat{s <= 256} let nat5 = (nat & nat & nat & nat & nat) let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256} let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\ x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256} inline_for_extraction noextract let max56 = pow56 - 1 let qelem_fits1 (x:uint64) (m:scale64) = uint_v x <= m * max56 let qelem_fits5 (f:qelem5) (m:scale64_5) = let (x1,x2,x3,x4,x5) = f in let (m1,m2,m3,m4,m5) = m in qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\ qelem_fits1 x5 m5 let qelem_wide_fits5 (f:qelem_wide5) (m:scale64_10) = let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = f in let (m1,m2,m3,m4,m5,m6,m7,m8,m9,m10) = m in qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\ qelem_fits1 x5 m5 /\ qelem_fits1 x6 m6 /\ qelem_fits1 x7 m7 /\ qelem_fits1 x8 m8 /\ qelem_fits1 x9 m9 /\ qelem_fits1 x10 m10 noextract val as_nat5: f:qelem5 -> GTot nat let as_nat5 f = let (s0, s1, s2, s3, s4) = f in v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224 noextract
{ "checked_file": "/", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Definitions.fst" }
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> Prims.GTot Prims.nat
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Lib.IntTypes.uint64", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.BignumQ.Definitions.pow56", "Hacl.Spec.BignumQ.Definitions.pow112", "Hacl.Spec.BignumQ.Definitions.pow168", "Hacl.Spec.BignumQ.Definitions.pow224", "Hacl.Spec.BignumQ.Definitions.pow280", "Hacl.Spec.BignumQ.Definitions.pow336", "Hacl.Spec.BignumQ.Definitions.pow392", "Hacl.Spec.BignumQ.Definitions.pow448", "Hacl.Spec.BignumQ.Definitions.pow504", "Prims.nat" ]
[]
false
false
false
false
false
let wide_as_nat5 f =
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 = f in v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224 + v s5 * pow280 + v s6 * pow336 + v s7 * pow392 + v s8 * pow448 + v s9 * pow504
false
EverParse3d.ErrorCode.fst
EverParse3d.ErrorCode.error_width
val error_width : Prims.int
let error_width = 4
{ "file_name": "src/3d/prelude/EverParse3d.ErrorCode.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 19, "end_line": 8, "start_col": 0, "start_line": 8 }
module EverParse3d.ErrorCode module U64 = FStar.UInt64 module BF = LowParse.BitFields inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.ErrorCode.fst" }
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.int
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let error_width =
4
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test3_ikm
val test3_ikm:lbytes 22
val test3_ikm:lbytes 22
let test3_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 168, "start_col": 0, "start_line": 161 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2 let test2_hash = Spec.Hash.Definitions.SHA2_256 let test2_ikm : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_salt : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x60uy; 0x61uy; 0x62uy; 0x63uy; 0x64uy; 0x65uy; 0x66uy; 0x67uy; 0x68uy; 0x69uy; 0x6auy; 0x6buy; 0x6cuy; 0x6duy; 0x6euy; 0x6fuy; 0x70uy; 0x71uy; 0x72uy; 0x73uy; 0x74uy; 0x75uy; 0x76uy; 0x77uy; 0x78uy; 0x79uy; 0x7auy; 0x7buy; 0x7cuy; 0x7duy; 0x7euy; 0x7fuy; 0x80uy; 0x81uy; 0x82uy; 0x83uy; 0x84uy; 0x85uy; 0x86uy; 0x87uy; 0x88uy; 0x89uy; 0x8auy; 0x8buy; 0x8cuy; 0x8duy; 0x8euy; 0x8fuy; 0x90uy; 0x91uy; 0x92uy; 0x93uy; 0x94uy; 0x95uy; 0x96uy; 0x97uy; 0x98uy; 0x99uy; 0x9auy; 0x9buy; 0x9cuy; 0x9duy; 0x9euy; 0x9fuy; 0xa0uy; 0xa1uy; 0xa2uy; 0xa3uy; 0xa4uy; 0xa5uy; 0xa6uy; 0xa7uy; 0xa8uy; 0xa9uy; 0xaauy; 0xabuy; 0xacuy; 0xaduy; 0xaeuy; 0xafuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_info : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0xb0uy; 0xb1uy; 0xb2uy; 0xb3uy; 0xb4uy; 0xb5uy; 0xb6uy; 0xb7uy; 0xb8uy; 0xb9uy; 0xbauy; 0xbbuy; 0xbcuy; 0xbduy; 0xbeuy; 0xbfuy; 0xc0uy; 0xc1uy; 0xc2uy; 0xc3uy; 0xc4uy; 0xc5uy; 0xc6uy; 0xc7uy; 0xc8uy; 0xc9uy; 0xcauy; 0xcbuy; 0xccuy; 0xcduy; 0xceuy; 0xcfuy; 0xd0uy; 0xd1uy; 0xd2uy; 0xd3uy; 0xd4uy; 0xd5uy; 0xd6uy; 0xd7uy; 0xd8uy; 0xd9uy; 0xdauy; 0xdbuy; 0xdcuy; 0xdduy; 0xdeuy; 0xdfuy; 0xe0uy; 0xe1uy; 0xe2uy; 0xe3uy; 0xe4uy; 0xe5uy; 0xe6uy; 0xe7uy; 0xe8uy; 0xe9uy; 0xeauy; 0xebuy; 0xecuy; 0xeduy; 0xeeuy; 0xefuy; 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy; 0xfauy; 0xfbuy; 0xfcuy; 0xfduy; 0xfeuy; 0xffuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_len = 82 let test2_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x06uy; 0xa6uy; 0xb8uy; 0x8cuy; 0x58uy; 0x53uy; 0x36uy; 0x1auy; 0x06uy; 0x10uy; 0x4cuy; 0x9cuy; 0xebuy; 0x35uy; 0xb4uy; 0x5cuy; 0xefuy; 0x76uy; 0x00uy; 0x14uy; 0x90uy; 0x46uy; 0x71uy; 0x01uy; 0x4auy; 0x19uy; 0x3fuy; 0x40uy; 0xc1uy; 0x5fuy; 0xc2uy; 0x44uy ] in assert_norm (List.Tot.length l == 32); of_list l let test2_expected_okm : lbytes 82 = let l = List.Tot.map u8_from_UInt8 [ 0xb1uy; 0x1euy; 0x39uy; 0x8duy; 0xc8uy; 0x03uy; 0x27uy; 0xa1uy; 0xc8uy; 0xe7uy; 0xf7uy; 0x8cuy; 0x59uy; 0x6auy; 0x49uy; 0x34uy; 0x4fuy; 0x01uy; 0x2euy; 0xdauy; 0x2duy; 0x4euy; 0xfauy; 0xd8uy; 0xa0uy; 0x50uy; 0xccuy; 0x4cuy; 0x19uy; 0xafuy; 0xa9uy; 0x7cuy; 0x59uy; 0x04uy; 0x5auy; 0x99uy; 0xcauy; 0xc7uy; 0x82uy; 0x72uy; 0x71uy; 0xcbuy; 0x41uy; 0xc6uy; 0x5euy; 0x59uy; 0x0euy; 0x09uy; 0xdauy; 0x32uy; 0x75uy; 0x60uy; 0x0cuy; 0x2fuy; 0x09uy; 0xb8uy; 0x36uy; 0x77uy; 0x93uy; 0xa9uy; 0xacuy; 0xa3uy; 0xdbuy; 0x71uy; 0xccuy; 0x30uy; 0xc5uy; 0x81uy; 0x79uy; 0xecuy; 0x3euy; 0x87uy; 0xc1uy; 0x4cuy; 0x01uy; 0xd5uy; 0xc1uy; 0xf3uy; 0x43uy; 0x4fuy; 0x1duy; 0x87uy ] in assert_norm (List.Tot.length l == 82); of_list l /// Test 3 let test3_hash = Spec.Hash.Definitions.SHA2_256
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 22
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let test3_ikm:lbytes 22 =
let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test2_expected_prk
val test2_expected_prk:lbytes 32
val test2_expected_prk:lbytes 32
let test2_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x06uy; 0xa6uy; 0xb8uy; 0x8cuy; 0x58uy; 0x53uy; 0x36uy; 0x1auy; 0x06uy; 0x10uy; 0x4cuy; 0x9cuy; 0xebuy; 0x35uy; 0xb4uy; 0x5cuy; 0xefuy; 0x76uy; 0x00uy; 0x14uy; 0x90uy; 0x46uy; 0x71uy; 0x01uy; 0x4auy; 0x19uy; 0x3fuy; 0x40uy; 0xc1uy; 0x5fuy; 0xc2uy; 0x44uy ] in assert_norm (List.Tot.length l == 32); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 136, "start_col": 0, "start_line": 128 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2 let test2_hash = Spec.Hash.Definitions.SHA2_256 let test2_ikm : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_salt : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x60uy; 0x61uy; 0x62uy; 0x63uy; 0x64uy; 0x65uy; 0x66uy; 0x67uy; 0x68uy; 0x69uy; 0x6auy; 0x6buy; 0x6cuy; 0x6duy; 0x6euy; 0x6fuy; 0x70uy; 0x71uy; 0x72uy; 0x73uy; 0x74uy; 0x75uy; 0x76uy; 0x77uy; 0x78uy; 0x79uy; 0x7auy; 0x7buy; 0x7cuy; 0x7duy; 0x7euy; 0x7fuy; 0x80uy; 0x81uy; 0x82uy; 0x83uy; 0x84uy; 0x85uy; 0x86uy; 0x87uy; 0x88uy; 0x89uy; 0x8auy; 0x8buy; 0x8cuy; 0x8duy; 0x8euy; 0x8fuy; 0x90uy; 0x91uy; 0x92uy; 0x93uy; 0x94uy; 0x95uy; 0x96uy; 0x97uy; 0x98uy; 0x99uy; 0x9auy; 0x9buy; 0x9cuy; 0x9duy; 0x9euy; 0x9fuy; 0xa0uy; 0xa1uy; 0xa2uy; 0xa3uy; 0xa4uy; 0xa5uy; 0xa6uy; 0xa7uy; 0xa8uy; 0xa9uy; 0xaauy; 0xabuy; 0xacuy; 0xaduy; 0xaeuy; 0xafuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_info : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0xb0uy; 0xb1uy; 0xb2uy; 0xb3uy; 0xb4uy; 0xb5uy; 0xb6uy; 0xb7uy; 0xb8uy; 0xb9uy; 0xbauy; 0xbbuy; 0xbcuy; 0xbduy; 0xbeuy; 0xbfuy; 0xc0uy; 0xc1uy; 0xc2uy; 0xc3uy; 0xc4uy; 0xc5uy; 0xc6uy; 0xc7uy; 0xc8uy; 0xc9uy; 0xcauy; 0xcbuy; 0xccuy; 0xcduy; 0xceuy; 0xcfuy; 0xd0uy; 0xd1uy; 0xd2uy; 0xd3uy; 0xd4uy; 0xd5uy; 0xd6uy; 0xd7uy; 0xd8uy; 0xd9uy; 0xdauy; 0xdbuy; 0xdcuy; 0xdduy; 0xdeuy; 0xdfuy; 0xe0uy; 0xe1uy; 0xe2uy; 0xe3uy; 0xe4uy; 0xe5uy; 0xe6uy; 0xe7uy; 0xe8uy; 0xe9uy; 0xeauy; 0xebuy; 0xecuy; 0xeduy; 0xeeuy; 0xefuy; 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy; 0xfauy; 0xfbuy; 0xfcuy; 0xfduy; 0xfeuy; 0xffuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_len = 82
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let test2_expected_prk:lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [ 0x06uy; 0xa6uy; 0xb8uy; 0x8cuy; 0x58uy; 0x53uy; 0x36uy; 0x1auy; 0x06uy; 0x10uy; 0x4cuy; 0x9cuy; 0xebuy; 0x35uy; 0xb4uy; 0x5cuy; 0xefuy; 0x76uy; 0x00uy; 0x14uy; 0x90uy; 0x46uy; 0x71uy; 0x01uy; 0x4auy; 0x19uy; 0x3fuy; 0x40uy; 0xc1uy; 0x5fuy; 0xc2uy; 0x44uy ] in assert_norm (List.Tot.length l == 32); of_list l
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test1_expected_prk
val test1_expected_prk:lbytes 32
val test1_expected_prk:lbytes 32
let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 56, "start_col": 0, "start_line": 48 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 32
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_expected_prk:lbytes 32 =
let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test3_salt
val test3_salt:lbytes 0
val test3_salt:lbytes 0
let test3_salt : lbytes 0 = let l = List.Tot.map u8_from_UInt8 [] in assert_norm (List.Tot.length l == 0); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 174, "start_col": 0, "start_line": 171 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2 let test2_hash = Spec.Hash.Definitions.SHA2_256 let test2_ikm : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_salt : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x60uy; 0x61uy; 0x62uy; 0x63uy; 0x64uy; 0x65uy; 0x66uy; 0x67uy; 0x68uy; 0x69uy; 0x6auy; 0x6buy; 0x6cuy; 0x6duy; 0x6euy; 0x6fuy; 0x70uy; 0x71uy; 0x72uy; 0x73uy; 0x74uy; 0x75uy; 0x76uy; 0x77uy; 0x78uy; 0x79uy; 0x7auy; 0x7buy; 0x7cuy; 0x7duy; 0x7euy; 0x7fuy; 0x80uy; 0x81uy; 0x82uy; 0x83uy; 0x84uy; 0x85uy; 0x86uy; 0x87uy; 0x88uy; 0x89uy; 0x8auy; 0x8buy; 0x8cuy; 0x8duy; 0x8euy; 0x8fuy; 0x90uy; 0x91uy; 0x92uy; 0x93uy; 0x94uy; 0x95uy; 0x96uy; 0x97uy; 0x98uy; 0x99uy; 0x9auy; 0x9buy; 0x9cuy; 0x9duy; 0x9euy; 0x9fuy; 0xa0uy; 0xa1uy; 0xa2uy; 0xa3uy; 0xa4uy; 0xa5uy; 0xa6uy; 0xa7uy; 0xa8uy; 0xa9uy; 0xaauy; 0xabuy; 0xacuy; 0xaduy; 0xaeuy; 0xafuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_info : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0xb0uy; 0xb1uy; 0xb2uy; 0xb3uy; 0xb4uy; 0xb5uy; 0xb6uy; 0xb7uy; 0xb8uy; 0xb9uy; 0xbauy; 0xbbuy; 0xbcuy; 0xbduy; 0xbeuy; 0xbfuy; 0xc0uy; 0xc1uy; 0xc2uy; 0xc3uy; 0xc4uy; 0xc5uy; 0xc6uy; 0xc7uy; 0xc8uy; 0xc9uy; 0xcauy; 0xcbuy; 0xccuy; 0xcduy; 0xceuy; 0xcfuy; 0xd0uy; 0xd1uy; 0xd2uy; 0xd3uy; 0xd4uy; 0xd5uy; 0xd6uy; 0xd7uy; 0xd8uy; 0xd9uy; 0xdauy; 0xdbuy; 0xdcuy; 0xdduy; 0xdeuy; 0xdfuy; 0xe0uy; 0xe1uy; 0xe2uy; 0xe3uy; 0xe4uy; 0xe5uy; 0xe6uy; 0xe7uy; 0xe8uy; 0xe9uy; 0xeauy; 0xebuy; 0xecuy; 0xeduy; 0xeeuy; 0xefuy; 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy; 0xfauy; 0xfbuy; 0xfcuy; 0xfduy; 0xfeuy; 0xffuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_len = 82 let test2_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x06uy; 0xa6uy; 0xb8uy; 0x8cuy; 0x58uy; 0x53uy; 0x36uy; 0x1auy; 0x06uy; 0x10uy; 0x4cuy; 0x9cuy; 0xebuy; 0x35uy; 0xb4uy; 0x5cuy; 0xefuy; 0x76uy; 0x00uy; 0x14uy; 0x90uy; 0x46uy; 0x71uy; 0x01uy; 0x4auy; 0x19uy; 0x3fuy; 0x40uy; 0xc1uy; 0x5fuy; 0xc2uy; 0x44uy ] in assert_norm (List.Tot.length l == 32); of_list l let test2_expected_okm : lbytes 82 = let l = List.Tot.map u8_from_UInt8 [ 0xb1uy; 0x1euy; 0x39uy; 0x8duy; 0xc8uy; 0x03uy; 0x27uy; 0xa1uy; 0xc8uy; 0xe7uy; 0xf7uy; 0x8cuy; 0x59uy; 0x6auy; 0x49uy; 0x34uy; 0x4fuy; 0x01uy; 0x2euy; 0xdauy; 0x2duy; 0x4euy; 0xfauy; 0xd8uy; 0xa0uy; 0x50uy; 0xccuy; 0x4cuy; 0x19uy; 0xafuy; 0xa9uy; 0x7cuy; 0x59uy; 0x04uy; 0x5auy; 0x99uy; 0xcauy; 0xc7uy; 0x82uy; 0x72uy; 0x71uy; 0xcbuy; 0x41uy; 0xc6uy; 0x5euy; 0x59uy; 0x0euy; 0x09uy; 0xdauy; 0x32uy; 0x75uy; 0x60uy; 0x0cuy; 0x2fuy; 0x09uy; 0xb8uy; 0x36uy; 0x77uy; 0x93uy; 0xa9uy; 0xacuy; 0xa3uy; 0xdbuy; 0x71uy; 0xccuy; 0x30uy; 0xc5uy; 0x81uy; 0x79uy; 0xecuy; 0x3euy; 0x87uy; 0xc1uy; 0x4cuy; 0x01uy; 0xd5uy; 0xc1uy; 0xf3uy; 0x43uy; 0x4fuy; 0x1duy; 0x87uy ] in assert_norm (List.Tot.length l == 82); of_list l /// Test 3 let test3_hash = Spec.Hash.Definitions.SHA2_256 let test3_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 0
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Nil" ]
[]
false
false
false
false
false
let test3_salt:lbytes 0 =
let l = List.Tot.map u8_from_UInt8 [] in assert_norm (List.Tot.length l == 0); of_list l
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test1_salt
val test1_salt:lbytes 13
val test1_salt:lbytes 13
let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 35, "start_col": 0, "start_line": 29 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 13
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_salt:lbytes 13 =
let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l
false
EverParse3d.ErrorCode.fst
EverParse3d.ErrorCode.is_error
val is_error (positionOrError: U64.t) : Tot bool
val is_error (positionOrError: U64.t) : Tot bool
let is_error (positionOrError: U64.t) : Tot bool = positionOrError `U64.gt` validator_max_length
{ "file_name": "src/3d/prelude/EverParse3d.ErrorCode.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 96, "end_line": 22, "start_col": 0, "start_line": 22 }
module EverParse3d.ErrorCode module U64 = FStar.UInt64 module BF = LowParse.BitFields inline_for_extraction noextract let error_width = 4 inline_for_extraction noextract let pos_width = normalize_term (64 - error_width) [@ CMacro ] let validator_max_length : (u: U64.t { 4 <= U64.v u /\ U64.v u == pow2 pos_width - 1 } ) = FStar.Math.Lemmas.pow2_le_compat 64 pos_width; [@inline_let] let x = U64.uint_to_t (pow2 pos_width - 1) in normalize_term_spec x; normalize_term x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.ErrorCode.fst" }
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
positionOrError: FStar.UInt64.t -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t", "FStar.UInt64.gt", "EverParse3d.ErrorCode.validator_max_length", "Prims.bool" ]
[]
false
false
false
true
false
let is_error (positionOrError: U64.t) : Tot bool =
positionOrError `U64.gt` validator_max_length
false
EverParse3d.ErrorCode.fst
EverParse3d.ErrorCode.pos_width
val pos_width : Prims.int
let pos_width = normalize_term (64 - error_width)
{ "file_name": "src/3d/prelude/EverParse3d.ErrorCode.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 49, "end_line": 12, "start_col": 0, "start_line": 12 }
module EverParse3d.ErrorCode module U64 = FStar.UInt64 module BF = LowParse.BitFields inline_for_extraction noextract let error_width = 4 inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.ErrorCode.fst" }
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.int
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term", "Prims.int", "Prims.op_Subtraction", "EverParse3d.ErrorCode.error_width" ]
[]
false
false
false
true
false
let pos_width =
normalize_term (64 - error_width)
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test_one
val test_one : v: Spec.HKDF.Test.vec -> FStar.All.ALL Prims.bool
let test_one (v:vec) = let Vec a salt ikm expected_prk info out_len expected_okm = v in let test_prk = HKDF.extract a salt ikm in let test_okm = HKDF.expand a expected_prk info out_len in IO.print_string "\nPRK:"; let r_a = PS.print_compare true (length expected_prk) expected_prk test_prk in IO.print_string "\nOKM:"; let r_b = PS.print_compare true (length expected_okm) expected_okm test_okm in let res = r_a && r_b in if r_a then IO.print_string "\nHKDF Extract: Success!\n" else IO.print_string "\nHKDF Extract: Failure :(\n"; if r_b then IO.print_string "HKDF Expand: Success!\n" else IO.print_string "HKDF Expand: Failure :(\n"; res
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 250, "start_col": 0, "start_line": 235 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2 let test2_hash = Spec.Hash.Definitions.SHA2_256 let test2_ikm : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_salt : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x60uy; 0x61uy; 0x62uy; 0x63uy; 0x64uy; 0x65uy; 0x66uy; 0x67uy; 0x68uy; 0x69uy; 0x6auy; 0x6buy; 0x6cuy; 0x6duy; 0x6euy; 0x6fuy; 0x70uy; 0x71uy; 0x72uy; 0x73uy; 0x74uy; 0x75uy; 0x76uy; 0x77uy; 0x78uy; 0x79uy; 0x7auy; 0x7buy; 0x7cuy; 0x7duy; 0x7euy; 0x7fuy; 0x80uy; 0x81uy; 0x82uy; 0x83uy; 0x84uy; 0x85uy; 0x86uy; 0x87uy; 0x88uy; 0x89uy; 0x8auy; 0x8buy; 0x8cuy; 0x8duy; 0x8euy; 0x8fuy; 0x90uy; 0x91uy; 0x92uy; 0x93uy; 0x94uy; 0x95uy; 0x96uy; 0x97uy; 0x98uy; 0x99uy; 0x9auy; 0x9buy; 0x9cuy; 0x9duy; 0x9euy; 0x9fuy; 0xa0uy; 0xa1uy; 0xa2uy; 0xa3uy; 0xa4uy; 0xa5uy; 0xa6uy; 0xa7uy; 0xa8uy; 0xa9uy; 0xaauy; 0xabuy; 0xacuy; 0xaduy; 0xaeuy; 0xafuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_info : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0xb0uy; 0xb1uy; 0xb2uy; 0xb3uy; 0xb4uy; 0xb5uy; 0xb6uy; 0xb7uy; 0xb8uy; 0xb9uy; 0xbauy; 0xbbuy; 0xbcuy; 0xbduy; 0xbeuy; 0xbfuy; 0xc0uy; 0xc1uy; 0xc2uy; 0xc3uy; 0xc4uy; 0xc5uy; 0xc6uy; 0xc7uy; 0xc8uy; 0xc9uy; 0xcauy; 0xcbuy; 0xccuy; 0xcduy; 0xceuy; 0xcfuy; 0xd0uy; 0xd1uy; 0xd2uy; 0xd3uy; 0xd4uy; 0xd5uy; 0xd6uy; 0xd7uy; 0xd8uy; 0xd9uy; 0xdauy; 0xdbuy; 0xdcuy; 0xdduy; 0xdeuy; 0xdfuy; 0xe0uy; 0xe1uy; 0xe2uy; 0xe3uy; 0xe4uy; 0xe5uy; 0xe6uy; 0xe7uy; 0xe8uy; 0xe9uy; 0xeauy; 0xebuy; 0xecuy; 0xeduy; 0xeeuy; 0xefuy; 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy; 0xfauy; 0xfbuy; 0xfcuy; 0xfduy; 0xfeuy; 0xffuy ] in assert_norm (List.Tot.length l == 80); of_list l let test2_len = 82 let test2_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x06uy; 0xa6uy; 0xb8uy; 0x8cuy; 0x58uy; 0x53uy; 0x36uy; 0x1auy; 0x06uy; 0x10uy; 0x4cuy; 0x9cuy; 0xebuy; 0x35uy; 0xb4uy; 0x5cuy; 0xefuy; 0x76uy; 0x00uy; 0x14uy; 0x90uy; 0x46uy; 0x71uy; 0x01uy; 0x4auy; 0x19uy; 0x3fuy; 0x40uy; 0xc1uy; 0x5fuy; 0xc2uy; 0x44uy ] in assert_norm (List.Tot.length l == 32); of_list l let test2_expected_okm : lbytes 82 = let l = List.Tot.map u8_from_UInt8 [ 0xb1uy; 0x1euy; 0x39uy; 0x8duy; 0xc8uy; 0x03uy; 0x27uy; 0xa1uy; 0xc8uy; 0xe7uy; 0xf7uy; 0x8cuy; 0x59uy; 0x6auy; 0x49uy; 0x34uy; 0x4fuy; 0x01uy; 0x2euy; 0xdauy; 0x2duy; 0x4euy; 0xfauy; 0xd8uy; 0xa0uy; 0x50uy; 0xccuy; 0x4cuy; 0x19uy; 0xafuy; 0xa9uy; 0x7cuy; 0x59uy; 0x04uy; 0x5auy; 0x99uy; 0xcauy; 0xc7uy; 0x82uy; 0x72uy; 0x71uy; 0xcbuy; 0x41uy; 0xc6uy; 0x5euy; 0x59uy; 0x0euy; 0x09uy; 0xdauy; 0x32uy; 0x75uy; 0x60uy; 0x0cuy; 0x2fuy; 0x09uy; 0xb8uy; 0x36uy; 0x77uy; 0x93uy; 0xa9uy; 0xacuy; 0xa3uy; 0xdbuy; 0x71uy; 0xccuy; 0x30uy; 0xc5uy; 0x81uy; 0x79uy; 0xecuy; 0x3euy; 0x87uy; 0xc1uy; 0x4cuy; 0x01uy; 0xd5uy; 0xc1uy; 0xf3uy; 0x43uy; 0x4fuy; 0x1duy; 0x87uy ] in assert_norm (List.Tot.length l == 82); of_list l /// Test 3 let test3_hash = Spec.Hash.Definitions.SHA2_256 let test3_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test3_salt : lbytes 0 = let l = List.Tot.map u8_from_UInt8 [] in assert_norm (List.Tot.length l == 0); of_list l let test3_info : lbytes 0 = let l = List.Tot.map u8_from_UInt8 [] in assert_norm (List.Tot.length l == 0); of_list l let test3_len = 42 let test3_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x19uy; 0xefuy; 0x24uy; 0xa3uy; 0x2cuy; 0x71uy; 0x7buy; 0x16uy; 0x7fuy; 0x33uy; 0xa9uy; 0x1duy; 0x6fuy; 0x64uy; 0x8buy; 0xdfuy; 0x96uy; 0x59uy; 0x67uy; 0x76uy; 0xafuy; 0xdbuy; 0x63uy; 0x77uy; 0xacuy; 0x43uy; 0x4cuy; 0x1cuy; 0x29uy; 0x3cuy; 0xcbuy; 0x04uy ] in assert_norm (List.Tot.length l == 32); of_list l let test3_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x8duy; 0xa4uy; 0xe7uy; 0x75uy; 0xa5uy; 0x63uy; 0xc1uy; 0x8fuy; 0x71uy; 0x5fuy; 0x80uy; 0x2auy; 0x06uy; 0x3cuy; 0x5auy; 0x31uy; 0xb8uy; 0xa1uy; 0x1fuy; 0x5cuy; 0x5euy; 0xe1uy; 0x87uy; 0x9euy; 0xc3uy; 0x45uy; 0x4euy; 0x5fuy; 0x3cuy; 0x73uy; 0x8duy; 0x2duy; 0x9duy; 0x20uy; 0x13uy; 0x95uy; 0xfauy; 0xa4uy; 0xb6uy; 0x1auy; 0x96uy; 0xc8uy ] in assert_norm (List.Tot.length l == 42); of_list l noeq type vec = | Vec : a:Spec.Hash.Definitions.fixed_len_alg -> salt:bytes{HMAC.keysized a (length salt)} -> ikm:bytes{HKDF.extract_ikm_length_pred a (length ikm)} -> expected_prk:lbytes (Spec.Hash.Definitions.hash_length a) -> info:bytes{HKDF.expand_info_length_pred a (length info)} -> out_len:nat{HKDF.expand_output_length_pred a out_len} -> expected_okm:lbytes out_len -> vec let _: squash (pow2 32 < pow2 61 /\ pow2 32 < pow2 125) = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32 let test_vectors: list vec = [ Vec test1_hash test1_salt test1_ikm test1_expected_prk test1_info test1_len test1_expected_okm; Vec test2_hash test2_salt test2_ikm test2_expected_prk test2_info test2_len test2_expected_okm; Vec test3_hash test3_salt test3_ikm test3_expected_prk test3_info test3_len test3_expected_okm ] #set-options "--ifuel 2"
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: Spec.HKDF.Test.vec -> FStar.All.ALL Prims.bool
FStar.All.ALL
[]
[]
[ "Spec.HKDF.Test.vec", "Spec.Hash.Definitions.fixed_len_alg", "Lib.ByteSequence.bytes", "Spec.Agile.HMAC.keysized", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.b2t", "Spec.Agile.HKDF.extract_ikm_length_pred", "Lib.ByteSequence.lbytes", "Spec.Hash.Definitions.hash_length", "Spec.Agile.HKDF.expand_info_length_pred", "Prims.nat", "Spec.Agile.HKDF.expand_output_length_pred", "Prims.bool", "Prims.unit", "FStar.IO.print_string", "Prims.op_AmpAmp", "Lib.PrintSequence.print_compare", "Spec.Agile.HKDF.lbytes", "Spec.Agile.HKDF.expand", "Spec.Agile.HKDF.extract" ]
[]
false
true
false
false
false
let test_one (v: vec) =
let Vec a salt ikm expected_prk info out_len expected_okm = v in let test_prk = HKDF.extract a salt ikm in let test_okm = HKDF.expand a expected_prk info out_len in IO.print_string "\nPRK:"; let r_a = PS.print_compare true (length expected_prk) expected_prk test_prk in IO.print_string "\nOKM:"; let r_b = PS.print_compare true (length expected_okm) expected_okm test_okm in let res = r_a && r_b in if r_a then IO.print_string "\nHKDF Extract: Success!\n" else IO.print_string "\nHKDF Extract: Failure :(\n"; if r_b then IO.print_string "HKDF Expand: Success!\n" else IO.print_string "HKDF Expand: Failure :(\n"; res
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test1_expected_okm
val test1_expected_okm:lbytes 42
val test1_expected_okm:lbytes 42
let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 69, "start_col": 0, "start_line": 59 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 42
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_expected_okm:lbytes 42 =
let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l
false
EverParse3d.ErrorCode.fst
EverParse3d.ErrorCode.is_success
val is_success (positionOrError: U64.t) : Tot bool
val is_success (positionOrError: U64.t) : Tot bool
let is_success (positionOrError: U64.t) : Tot bool = positionOrError `U64.lte` validator_max_length
{ "file_name": "src/3d/prelude/EverParse3d.ErrorCode.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 99, "end_line": 24, "start_col": 0, "start_line": 24 }
module EverParse3d.ErrorCode module U64 = FStar.UInt64 module BF = LowParse.BitFields inline_for_extraction noextract let error_width = 4 inline_for_extraction noextract let pos_width = normalize_term (64 - error_width) [@ CMacro ] let validator_max_length : (u: U64.t { 4 <= U64.v u /\ U64.v u == pow2 pos_width - 1 } ) = FStar.Math.Lemmas.pow2_le_compat 64 pos_width; [@inline_let] let x = U64.uint_to_t (pow2 pos_width - 1) in normalize_term_spec x; normalize_term x let is_error (positionOrError: U64.t) : Tot bool = positionOrError `U64.gt` validator_max_length
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.ErrorCode.fst" }
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
positionOrError: FStar.UInt64.t -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t", "FStar.UInt64.lte", "EverParse3d.ErrorCode.validator_max_length", "Prims.bool" ]
[]
false
false
false
true
false
let is_success (positionOrError: U64.t) : Tot bool =
positionOrError `U64.lte` validator_max_length
false
EverParse3d.ErrorCode.fst
EverParse3d.ErrorCode.pos_t
val pos_t : Type0
let pos_t = (pos: U64.t {is_success pos})
{ "file_name": "src/3d/prelude/EverParse3d.ErrorCode.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 41, "end_line": 32, "start_col": 0, "start_line": 32 }
module EverParse3d.ErrorCode module U64 = FStar.UInt64 module BF = LowParse.BitFields inline_for_extraction noextract let error_width = 4 inline_for_extraction noextract let pos_width = normalize_term (64 - error_width) [@ CMacro ] let validator_max_length : (u: U64.t { 4 <= U64.v u /\ U64.v u == pow2 pos_width - 1 } ) = FStar.Math.Lemmas.pow2_le_compat 64 pos_width; [@inline_let] let x = U64.uint_to_t (pow2 pos_width - 1) in normalize_term_spec x; normalize_term x let is_error (positionOrError: U64.t) : Tot bool = positionOrError `U64.gt` validator_max_length let is_success (positionOrError: U64.t) : Tot bool = positionOrError `U64.lte` validator_max_length inline_for_extraction noextract type validator_error = (u: U64.t { is_error u } ) inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.ErrorCode.fst" }
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t", "Prims.b2t", "EverParse3d.ErrorCode.is_success" ]
[]
false
false
false
true
true
let pos_t =
(pos: U64.t{is_success pos})
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.uint32
val uint32 : Type0
let uint32 = Lib.IntTypes.uint32
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 25, "start_col": 0, "start_line": 25 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "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.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint32" ]
[]
false
false
false
true
true
let uint32 =
Lib.IntTypes.uint32
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_mul1_add_in_place
val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res))
val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res))
let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 97, "start_col": 0, "start_line": 76 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
aLen: Lib.IntTypes.size_t -> a: Hacl.Bignum.Definitions.lbignum t aLen -> l: Hacl.Bignum.Definitions.limb t -> res: Hacl.Bignum.Definitions.lbignum t aLen -> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t)
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Lib.fill_elems4", "Hacl.Spec.Bignum.Definitions.limb", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.op_Array_Assignment", "Hacl.Bignum.Base.mul_wide_add2_st", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Multiplication.bn_mul1_add_in_place_f", "Lib.Buffer.as_seq", "LowStar.Monotonic.Buffer.loc", "Prims.l_and", "LowStar.Monotonic.Buffer.loc_disjoint", "Lib.Buffer.loc", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "Lib.IntTypes.size_nat", "Prims.eq2", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let bn_mul1_add_in_place #t aLen a l res =
push_frame (); let c = create 1ul (uint #t 0) in [@@ inline_let ]let refl h i = LSeq.index (as_seq h c) 0 in [@@ inline_let ]let footprint (i: size_nat{i <= v aLen}) : GTot (l: B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@@ inline_let ]let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i); let c = c.(0ul) in pop_frame (); c
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.as_raw
val as_raw (#fs: field_spec) (x: t fs) : B.buffer (limb fs)
val as_raw (#fs: field_spec) (x: t fs) : B.buffer (limb fs)
let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 63, "end_line": 40, "start_col": 0, "start_line": 40 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 }
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "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.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Hacl.Streaming.Poly1305.t fs -> LowStar.Buffer.buffer (Hacl.Impl.Poly1305.Fields.limb fs)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "Hacl.Streaming.Poly1305.t", "LowStar.Buffer.buffer", "Hacl.Impl.Poly1305.Fields.limb" ]
[]
false
false
false
false
false
let as_raw (#fs: field_spec) (x: t fs) : B.buffer (limb fs) =
x
false
Spec.HKDF.Test.fst
Spec.HKDF.Test.test2_ikm
val test2_ikm:lbytes 80
val test2_ikm:lbytes 80
let test2_ikm : lbytes 80 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l
{ "file_name": "specs/tests/Spec.HKDF.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 90, "start_col": 0, "start_line": 76 }
module Spec.HKDF.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence module PS = Lib.PrintSequence module HMAC = Spec.Agile.HMAC module HKDF = Spec.Agile.HKDF #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Test 1 let test1_hash = Spec.Hash.Definitions.SHA2_256 let test1_ikm : lbytes 22 = let l = List.Tot.map u8_from_UInt8 [ 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy; 0x0buy ] in assert_norm (List.Tot.length l == 22); of_list l let test1_salt : lbytes 13 = let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy ] in assert_norm (List.Tot.length l == 13); of_list l let test1_info : lbytes 10 = let l = List.Tot.map u8_from_UInt8 [ 0xf0uy; 0xf1uy; 0xf2uy; 0xf3uy; 0xf4uy; 0xf5uy; 0xf6uy; 0xf7uy; 0xf8uy; 0xf9uy ] in assert_norm (List.Tot.length l == 10); of_list l let test1_len = 42 let test1_expected_prk : lbytes 32 = let l = List.Tot.map u8_from_UInt8 [ 0x07uy; 0x77uy; 0x09uy; 0x36uy; 0x2cuy; 0x2euy; 0x32uy; 0xdfuy; 0x0duy; 0xdcuy; 0x3fuy; 0x0duy; 0xc4uy; 0x7buy; 0xbauy; 0x63uy; 0x90uy; 0xb6uy; 0xc7uy; 0x3buy; 0xb5uy; 0x0fuy; 0x9cuy; 0x31uy; 0x22uy; 0xecuy; 0x84uy; 0x4auy; 0xd7uy; 0xc2uy; 0xb3uy; 0xe5uy ] in assert_norm (List.Tot.length l == 32); of_list l let test1_expected_okm : lbytes 42 = let l = List.Tot.map u8_from_UInt8 [ 0x3cuy; 0xb2uy; 0x5fuy; 0x25uy; 0xfauy; 0xacuy; 0xd5uy; 0x7auy; 0x90uy; 0x43uy; 0x4fuy; 0x64uy; 0xd0uy; 0x36uy; 0x2fuy; 0x2auy; 0x2duy; 0x2duy; 0x0auy; 0x90uy; 0xcfuy; 0x1auy; 0x5auy; 0x4cuy; 0x5duy; 0xb0uy; 0x2duy; 0x56uy; 0xecuy; 0xc4uy; 0xc5uy; 0xbfuy; 0x34uy; 0x00uy; 0x72uy; 0x08uy; 0xd5uy; 0xb8uy; 0x87uy; 0x18uy; 0x58uy; 0x65uy ] in assert_norm (List.Tot.length l == 42); of_list l /// Test 2 let test2_hash = Spec.Hash.Definitions.SHA2_256
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.IO.fst.checked" ], "interface_file": false, "source_file": "Spec.HKDF.Test.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.HKDF", "short_module": "HKDF" }, { "abbrev": true, "full_module": "Spec.Agile.HMAC", "short_module": "HMAC" }, { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.HKDF", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) 80
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
false
false
let test2_ikm:lbytes 80 =
let l = List.Tot.map u8_from_UInt8 [ 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; 0x09uy; 0x0auy; 0x0buy; 0x0cuy; 0x0duy; 0x0euy; 0x0fuy; 0x10uy; 0x11uy; 0x12uy; 0x13uy; 0x14uy; 0x15uy; 0x16uy; 0x17uy; 0x18uy; 0x19uy; 0x1auy; 0x1buy; 0x1cuy; 0x1duy; 0x1euy; 0x1fuy; 0x20uy; 0x21uy; 0x22uy; 0x23uy; 0x24uy; 0x25uy; 0x26uy; 0x27uy; 0x28uy; 0x29uy; 0x2auy; 0x2buy; 0x2cuy; 0x2duy; 0x2euy; 0x2fuy; 0x30uy; 0x31uy; 0x32uy; 0x33uy; 0x34uy; 0x35uy; 0x36uy; 0x37uy; 0x38uy; 0x39uy; 0x3auy; 0x3buy; 0x3cuy; 0x3duy; 0x3euy; 0x3fuy; 0x40uy; 0x41uy; 0x42uy; 0x43uy; 0x44uy; 0x45uy; 0x46uy; 0x47uy; 0x48uy; 0x49uy; 0x4auy; 0x4buy; 0x4cuy; 0x4duy; 0x4euy; 0x4fuy ] in assert_norm (List.Tot.length l == 80); of_list l
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.t
val t : fs: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 }
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 67, "end_line": 37, "start_col": 0, "start_line": 37 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100"
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "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.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "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": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fs: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "LowStar.Buffer.buffer", "Hacl.Impl.Poly1305.Fields.limb", "Prims.eq2", "Prims.int", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder" ]
[]
false
false
false
true
true
let t (fs: field_spec) =
b: B.buffer (limb fs) {B.length b == 25}
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_sqr_diag
val bn_sqr_diag: #t:limb_t -> aLen:size_t{v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a /\ as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a))
val bn_sqr_diag: #t:limb_t -> aLen:size_t{v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a /\ as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a))
let bn_sqr_diag #t aLen a res = let h0 = ST.get () in [@inline_let] let spec h = SS.bn_sqr_diag_f (as_seq h a) in loop1 h0 aLen res spec (fun i -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i); let (hi, lo) = mul_wide a.(i) a.(i) in res.(2ul *! i) <- lo; res.(2ul *! i +! 1ul) <- hi)
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 191, "start_col": 0, "start_line": 180 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j) inline_for_extraction noextract let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) inline_for_extraction noextract val bn_mul: #t:limb_t -> bn_mul_st t let bn_mul #t aLen a bLen b res = [@inline_let] let resLen = aLen +! bLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@ inline_let] let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in loop1 h0 bLen res spec (fun j -> Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j); let bj = b.(j) in res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res ) [@CInline] let bn_mul_u32 : bn_mul_st U32 = bn_mul [@CInline] let bn_mul_u64 : bn_mul_st U64 = bn_mul inline_for_extraction noextract let bn_mul_u (#t:limb_t) : bn_mul_st t = match t with | U32 -> bn_mul_u32 | U64 -> bn_mul_u64 inline_for_extraction noextract val bn_sqr_diag: #t:limb_t -> aLen:size_t{v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a /\ as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
aLen: Lib.IntTypes.size_t{Lib.IntTypes.v aLen + Lib.IntTypes.v aLen <= Lib.IntTypes.max_size_t} -> a: Hacl.Bignum.Definitions.lbignum t aLen -> res: Hacl.Bignum.Definitions.lbignum t (aLen +! aLen) -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.Buffer.loop1", "Hacl.Bignum.Definitions.limb", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.limb", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Prims.unit", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Base.mul_wide", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Lib.LoopCombinators.unfold_repeati", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "FStar.Monotonic.HyperStack.mem", "Prims.nat", "Hacl.Spec.Bignum.Squaring.bn_sqr_diag_f", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let bn_sqr_diag #t aLen a res =
let h0 = ST.get () in [@@ inline_let ]let spec h = SS.bn_sqr_diag_f (as_seq h a) in loop1 h0 aLen res spec (fun i -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i); let hi, lo = mul_wide a.(i) a.(i) in res.(2ul *! i) <- lo; res.(2ul *! i +! 1ul) <- hi)
false