effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Pure
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Greater_Greater_Hat = shift_right
let op_Greater_Greater_Hat =
false
null
false
shift_right
{ "checked_file": "FStar.UInt8.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt8.fsti" }
[]
[ "FStar.UInt8.shift_right" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 8 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum value for this type *) inline_for_extraction let n_minus_one = UInt32.uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand unfold let op_Bar_Hat = logor
false
false
FStar.UInt8.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Greater_Greater_Hat : a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t
[]
FStar.UInt8.op_Greater_Greater_Hat
{ "file_name": "ulib/FStar.UInt8.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 47, "end_line": 330, "start_col": 36, "start_line": 330 }
Prims.Pure
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Less_Less_Hat = shift_left
let op_Less_Less_Hat =
false
null
false
shift_left
{ "checked_file": "FStar.UInt8.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt8.fsti" }
[]
[ "FStar.UInt8.shift_left" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 8 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum value for this type *) inline_for_extraction let n_minus_one = UInt32.uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand
false
false
FStar.UInt8.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Less_Less_Hat : a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t
[]
FStar.UInt8.op_Less_Less_Hat
{ "file_name": "ulib/FStar.UInt8.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 40, "end_line": 329, "start_col": 30, "start_line": 329 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Greater_Equals_Hat = gte
let op_Greater_Equals_Hat =
false
null
false
gte
{ "checked_file": "FStar.UInt8.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt8.fsti" }
[ "total" ]
[ "FStar.UInt8.gte" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 8 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum value for this type *) inline_for_extraction let n_minus_one = UInt32.uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand unfold let op_Bar_Hat = logor unfold let op_Less_Less_Hat = shift_left unfold let op_Greater_Greater_Hat = shift_right unfold let op_Equals_Hat = eq
false
true
FStar.UInt8.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Greater_Equals_Hat : a: FStar.UInt8.t -> b: FStar.UInt8.t -> Prims.bool
[]
FStar.UInt8.op_Greater_Equals_Hat
{ "file_name": "ulib/FStar.UInt8.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.UInt8.t -> Prims.bool
{ "end_col": 38, "end_line": 333, "start_col": 35, "start_line": 333 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_minus_one = UInt32.uint_to_t (n - 1)
let n_minus_one =
false
null
false
UInt32.uint_to_t (n - 1)
{ "checked_file": "FStar.UInt8.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt8.fsti" }
[ "total" ]
[ "FStar.UInt32.uint_to_t", "Prims.op_Subtraction", "FStar.UInt8.n" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 8 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum value for this type *)
false
true
FStar.UInt8.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_minus_one : FStar.UInt32.t
[]
FStar.UInt8.n_minus_one
{ "file_name": "ulib/FStar.UInt8.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.UInt32.t
{ "end_col": 42, "end_line": 243, "start_col": 18, "start_line": 243 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let minus (a:t) = add_mod (lognot a) (uint_to_t 1)
let minus (a: t) =
false
null
false
add_mod (lognot a) (uint_to_t 1)
{ "checked_file": "FStar.UInt8.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt8.fsti" }
[ "total" ]
[ "FStar.UInt8.t", "FStar.UInt8.add_mod", "FStar.UInt8.lognot", "FStar.UInt8.uint_to_t" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 8 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *)
false
true
FStar.UInt8.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val minus : a: FStar.UInt8.t -> FStar.UInt8.t
[]
FStar.UInt8.minus
{ "file_name": "ulib/FStar.UInt8.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> FStar.UInt8.t
{ "end_col": 50, "end_line": 239, "start_col": 18, "start_line": 239 }
Prims.Pure
val gte_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0)))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c
val gte_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) let gte_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) =
false
null
false
let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c
{ "checked_file": "FStar.UInt8.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt8.fsti" }
[]
[ "FStar.UInt8.t", "Prims.unit", "FStar.UInt.lemma_msb_gte", "FStar.UInt8.n", "FStar.UInt8.v", "FStar.UInt8.lemma_sub_msbs", "FStar.UInt8.sub_mod", "FStar.UInt8.uint_to_t", "FStar.UInt8.shift_right", "FStar.UInt8.n_minus_one", "FStar.UInt8.logxor", "FStar.UInt8.logor", "Prims.l_True", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_LessThan" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 8 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum value for this type *) inline_for_extraction let n_minus_one = UInt32.uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\
false
false
FStar.UInt8.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 80, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gte_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0)))
[]
FStar.UInt8.gte_mask
{ "file_name": "ulib/FStar.UInt8.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 5, "end_line": 311, "start_col": 3, "start_line": 299 }
Prims.Pure
val eq_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0)))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c
val eq_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) let eq_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) =
false
null
false
let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then (logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n)) else (logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n)); c
{ "checked_file": "FStar.UInt8.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt8.fsti" }
[]
[ "FStar.UInt8.t", "Prims.unit", "Prims.op_Equality", "Prims._assert", "Prims.b2t", "FStar.UInt.uint_t", "FStar.UInt8.n", "FStar.UInt8.v", "FStar.UInt.ones", "Prims.l_and", "Prims.int", "FStar.UInt.logor_lemma_1", "FStar.UInt.lognot_lemma_1", "FStar.UInt.logxor_self", "Prims.bool", "FStar.UInt.zero", "FStar.UInt.lemma_minus_zero", "FStar.UInt.lemma_msb_pow2", "FStar.UInt8.lognot", "FStar.UInt.logxor_neq_nonzero", "FStar.UInt8.sub_mod", "FStar.UInt8.uint_to_t", "FStar.UInt8.shift_right", "FStar.UInt8.n_minus_one", "FStar.UInt8.logor", "FStar.UInt8.minus", "FStar.UInt8.logxor", "Prims.l_True", "Prims.l_imp", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_disEquality" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt8 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 8 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum value for this type *) inline_for_extraction let n_minus_one = UInt32.uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\
false
false
FStar.UInt8.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 80, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eq_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0)))
[]
FStar.UInt8.eq_mask
{ "file_name": "ulib/FStar.UInt8.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
{ "end_col": 5, "end_line": 282, "start_col": 3, "start_line": 260 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bytes = Seq.seq uint8
let bytes =
false
null
false
Seq.seq uint8
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Spec.Agile.AEAD.uint8" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// -------------------
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bytes : Type0
[]
EverCrypt.AEAD.bytes
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 25, "end_line": 129, "start_col": 12, "start_line": 129 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p)
let freeable (#a: alg) (h: HS.mem) (p: state a) =
false
null
false
B.freeable p /\ freeable_s (B.deref h p)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.alg", "FStar.Monotonic.HyperStack.mem", "EverCrypt.AEAD.state", "Prims.l_and", "LowStar.Monotonic.Buffer.freeable", "EverCrypt.AEAD.state_s", "LowStar.Buffer.trivial_preorder", "EverCrypt.AEAD.freeable_s", "LowStar.Monotonic.Buffer.deref", "Prims.logical" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val freeable : h: FStar.Monotonic.HyperStack.mem -> p: EverCrypt.AEAD.state a -> Prims.logical
[]
EverCrypt.AEAD.freeable
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> p: EverCrypt.AEAD.state a -> Prims.logical
{ "end_col": 42, "end_line": 54, "start_col": 2, "start_line": 54 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let state alg = B.pointer (state_s alg)
let state alg =
false
null
false
B.pointer (state_s alg)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.alg", "LowStar.Buffer.pointer", "EverCrypt.AEAD.state_s" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val state : alg: Spec.Agile.AEAD.alg -> Type0
[]
EverCrypt.AEAD.state
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Spec.Agile.AEAD.alg -> Type0
{ "end_col": 39, "end_line": 47, "start_col": 16, "start_line": 47 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a }
let ad_p a =
false
null
false
ad: B.buffer uint8 {B.length ad <= max_length a}
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "Prims.b2t", "FStar.Integers.op_Less_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.max_length" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)}
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ad_p : a: Spec.Agile.AEAD.supported_alg -> Type0
[]
EverCrypt.AEAD.ad_p
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.supported_alg -> Type0
{ "end_col": 62, "end_line": 234, "start_col": 13, "start_line": 234 }
Prims.Tot
val preserves_freeable (#a: _) (s: state a) (h0 h1: HS.mem) : Type0
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s
val preserves_freeable (#a: _) (s: state a) (h0 h1: HS.mem) : Type0 let preserves_freeable #a (s: state a) (h0: HS.mem) (h1: HS.mem) : Type0 =
false
null
false
freeable h0 s ==> freeable h1 s
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.alg", "EverCrypt.AEAD.state", "FStar.Monotonic.HyperStack.mem", "Prims.l_imp", "EverCrypt.AEAD.freeable" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val preserves_freeable (#a: _) (s: state a) (h0 h1: HS.mem) : Type0
[]
EverCrypt.AEAD.preserves_freeable
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: EverCrypt.AEAD.state a -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
{ "end_col": 33, "end_line": 58, "start_col": 2, "start_line": 58 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let plain_p a = p:B.buffer uint8 { B.length p <= max_length a }
let plain_p a =
false
null
false
p: B.buffer uint8 {B.length p <= max_length a}
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "Prims.b2t", "FStar.Integers.op_Less_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.max_length" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a }
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val plain_p : a: Spec.Agile.AEAD.supported_alg -> Type0
[]
EverCrypt.AEAD.plain_p
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.supported_alg -> Type0
{ "end_col": 63, "end_line": 237, "start_col": 16, "start_line": 237 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True
let config_pre a =
false
null
false
match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.alg", "Prims.l_and", "Prims.b2t", "EverCrypt.TargetConfig.hacl_can_compile_vale", "Vale.X64.CPU_Features_s.aesni_enabled", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "Vale.X64.CPU_Features_s.avx_enabled", "Vale.X64.CPU_Features_s.movbe_enabled", "Vale.X64.CPU_Features_s.sse_enabled", "Prims.l_True", "Prims.logical" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val config_pre : a: Spec.Agile.AEAD.alg -> Prims.logical
[]
EverCrypt.AEAD.config_pre
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.alg -> Prims.logical
{ "end_col": 13, "end_line": 94, "start_col": 2, "start_line": 87 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cipher_p a = p:B.buffer uint8 { B.length p + tag_length a <= max_length a }
let cipher_p a =
false
null
false
p: B.buffer uint8 {B.length p + tag_length a <= max_length a}
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.alg", "Prims.b2t", "Spec.Agile.AEAD.is_supported_alg", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "FStar.Integers.op_Less_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Integers.op_Plus", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.tag_length", "Spec.Agile.AEAD.max_length" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a } inline_for_extraction noextract let plain_p a = p:B.buffer uint8 { B.length p <= max_length a }
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cipher_p : a: Spec.Agile.AEAD.alg{Spec.Agile.AEAD.is_supported_alg a} -> Type0
[]
EverCrypt.AEAD.cipher_p
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.alg{Spec.Agile.AEAD.is_supported_alg a} -> Type0
{ "end_col": 79, "end_line": 240, "start_col": 17, "start_line": 240 }
Prims.GTot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s)))
let footprint (#a: alg) (m: HS.mem) (s: state a) =
false
null
false
let open B in loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "sometrivial" ]
[ "Spec.Agile.AEAD.alg", "FStar.Monotonic.HyperStack.mem", "EverCrypt.AEAD.state", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "EverCrypt.AEAD.state_s", "LowStar.Buffer.trivial_preorder", "EverCrypt.AEAD.footprint_s", "LowStar.Monotonic.Buffer.deref", "LowStar.Monotonic.Buffer.loc" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val footprint : m: FStar.Monotonic.HyperStack.mem -> s: EverCrypt.AEAD.state a -> Prims.GTot LowStar.Monotonic.Buffer.loc
[]
EverCrypt.AEAD.footprint
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: FStar.Monotonic.HyperStack.mem -> s: EverCrypt.AEAD.state a -> Prims.GTot LowStar.Monotonic.Buffer.loc
{ "end_col": 66, "end_line": 62, "start_col": 2, "start_line": 62 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)}
let iv_p a =
false
null
false
iv: B.buffer uint8 {iv_length a (B.length iv)}
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "Spec.Agile.AEAD.iv_length", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// --------------------------------
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val iv_p : a: Spec.Agile.AEAD.supported_alg -> Type0
[]
EverCrypt.AEAD.iv_p
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.supported_alg -> Type0
{ "end_col": 59, "end_line": 231, "start_col": 13, "start_line": 231 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let encrypt_live_disjoint_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = MB.(all_live h0 [ buf iv; buf ad; buf plain; buf cipher; buf tag ]) /\ (B.disjoint plain cipher \/ plain == cipher) /\ B.disjoint cipher tag /\ B.disjoint iv cipher /\ B.disjoint iv tag /\ B.disjoint plain tag /\ B.disjoint plain ad /\ B.disjoint ad cipher /\ B.disjoint ad tag
let encrypt_live_disjoint_pre (a: supported_alg) (iv: iv_p a) (iv_len: UInt32.t) (ad: ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher tag: B.buffer uint8) (h0: HS.mem) =
false
null
false
MB.(all_live h0 [buf iv; buf ad; buf plain; buf cipher; buf tag]) /\ (B.disjoint plain cipher \/ plain == cipher) /\ B.disjoint cipher tag /\ B.disjoint iv cipher /\ B.disjoint iv tag /\ B.disjoint plain tag /\ B.disjoint plain ad /\ B.disjoint ad cipher /\ B.disjoint ad tag
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "EverCrypt.AEAD.ad_p", "EverCrypt.AEAD.plain_p", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Monotonic.Buffer.all_live", "Prims.Cons", "LowStar.Monotonic.Buffer.buf_t", "LowStar.Monotonic.Buffer.buf", "LowStar.Buffer.trivial_preorder", "Prims.Nil", "Prims.l_or", "LowStar.Monotonic.Buffer.disjoint", "Prims.eq2", "Prims.logical" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a } inline_for_extraction noextract let plain_p a = p:B.buffer uint8 { B.length p <= max_length a } inline_for_extraction noextract let cipher_p a = p:B.buffer uint8 { B.length p + tag_length a <= max_length a } // SNIPPET_START: encrypt_pre inline_for_extraction noextract let encrypt_gen_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = v iv_len = B.length iv /\ v iv_len > 0 /\ v ad_len = B.length ad /\ v ad_len <= pow2 31 /\ v plain_len = B.length plain /\ v plain_len <= max_length a /\ B.length cipher = B.length plain /\ B.length tag = tag_length a inline_for_extraction noextract let encrypt_live_disjoint_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem)
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val encrypt_live_disjoint_pre : a: Spec.Agile.AEAD.supported_alg -> iv: EverCrypt.AEAD.iv_p a -> iv_len: FStar.UInt32.t -> ad: EverCrypt.AEAD.ad_p a -> ad_len: FStar.UInt32.t -> plain: EverCrypt.AEAD.plain_p a -> plain_len: FStar.UInt32.t -> cipher: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> tag: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> h0: FStar.Monotonic.HyperStack.mem -> Prims.logical
[]
EverCrypt.AEAD.encrypt_live_disjoint_pre
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.supported_alg -> iv: EverCrypt.AEAD.iv_p a -> iv_len: FStar.UInt32.t -> ad: EverCrypt.AEAD.ad_p a -> ad_len: FStar.UInt32.t -> plain: EverCrypt.AEAD.plain_p a -> plain_len: FStar.UInt32.t -> cipher: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> tag: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> h0: FStar.Monotonic.HyperStack.mem -> Prims.logical
{ "end_col": 43, "end_line": 279, "start_col": 2, "start_line": 273 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k)
let alloca_st (a: alg) =
false
null
false
k: B.buffer uint8 {B.length k = key_length a} -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> invariant h1 s /\ B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ as_kv (B.deref h1 s) == B.as_seq h0 k)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.alg", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "LowStar.Buffer.pointer", "EverCrypt.AEAD.state_s", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "EverCrypt.AEAD.config_pre", "Spec.Agile.AEAD.is_supported_alg", "EverCrypt.AEAD.invariant", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "LowStar.Monotonic.Buffer.fresh_loc", "EverCrypt.AEAD.footprint", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.loc_region_only", "FStar.Monotonic.HyperStack.get_tip", "Prims.eq2", "FStar.Seq.Base.seq", "EverCrypt.AEAD.as_kv", "LowStar.Monotonic.Buffer.deref", "LowStar.Monotonic.Buffer.as_seq" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val alloca_st : a: Spec.Agile.AEAD.alg -> Type0
[]
EverCrypt.AEAD.alloca_st
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.alg -> Type0
{ "end_col": 44, "end_line": 197, "start_col": 2, "start_line": 182 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let encrypt_expand_pre (a: supported_alg) (k:B.buffer uint8 { B.length k = key_length a }) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( B.live h0 k /\ B.disjoint k cipher /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0)
let encrypt_expand_pre (a: supported_alg) (k: B.buffer uint8 {B.length k = key_length a}) (iv: iv_p a) (iv_len: UInt32.t) (ad: ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher tag: B.buffer uint8) (h0: HS.mem) =
false
null
false
encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ (B.live h0 k /\ B.disjoint k cipher /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "EverCrypt.AEAD.ad_p", "EverCrypt.AEAD.plain_p", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverCrypt.AEAD.encrypt_gen_pre", "LowStar.Monotonic.Buffer.live", "LowStar.Monotonic.Buffer.disjoint", "EverCrypt.AEAD.encrypt_live_disjoint_pre", "Prims.logical" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a } inline_for_extraction noextract let plain_p a = p:B.buffer uint8 { B.length p <= max_length a } inline_for_extraction noextract let cipher_p a = p:B.buffer uint8 { B.length p + tag_length a <= max_length a } // SNIPPET_START: encrypt_pre inline_for_extraction noextract let encrypt_gen_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = v iv_len = B.length iv /\ v iv_len > 0 /\ v ad_len = B.length ad /\ v ad_len <= pow2 31 /\ v plain_len = B.length plain /\ v plain_len <= max_length a /\ B.length cipher = B.length plain /\ B.length tag = tag_length a inline_for_extraction noextract let encrypt_live_disjoint_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = MB.(all_live h0 [ buf iv; buf ad; buf plain; buf cipher; buf tag ]) /\ (B.disjoint plain cipher \/ plain == cipher) /\ B.disjoint cipher tag /\ B.disjoint iv cipher /\ B.disjoint iv tag /\ B.disjoint plain tag /\ B.disjoint plain ad /\ B.disjoint ad cipher /\ B.disjoint ad tag inline_for_extraction noextract let encrypt_pre (a: supported_alg) (s:B.pointer_or_null (state_s a)) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer plain)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0) // SNIPPET_END: encrypt_pre inline_for_extraction noextract let encrypt_st (a: supported_alg) = s:B.pointer_or_null (state_s a) -> iv:iv_p a -> iv_len: UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> plain: plain_p a -> plain_len: UInt32.t { v plain_len = B.length plain /\ v plain_len <= max_length a } -> cipher: B.buffer uint8 { B.length cipher = B.length plain } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> Stack error_code (requires encrypt_pre a s iv iv_len ad ad_len plain plain_len cipher tag) (ensures fun h0 r h1 -> match r with | Success -> not (B.g_is_null s) /\ B.(modifies (loc_union (footprint h1 s) (loc_union (loc_buffer cipher) (loc_buffer tag))) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain)) | InvalidKey -> B.g_is_null s /\ B.(modifies loc_none h0 h1) | _ -> False) /// This function takes a previously expanded key and performs encryption. /// /// Possible return values are: /// - ``Success``: encryption was successfully performed /// - ``InvalidKey``: the function was passed a NULL expanded key (see above) (** @type: true *) [@@ Comment "Encrypt and authenticate a message (`plain`) with associated data (`ad`). @param s Pointer to the The AEAD state created by `EverCrypt_AEAD_create_in`. It already contains the encryption key. @param iv Pointer to `iv_len` bytes of memory where the nonce is read from. @param iv_len Length of the nonce. Note: ChaCha20Poly1305 requires a 12 byte nonce. @param ad Pointer to `ad_len` bytes of memory where the associated data is read from. @param ad_len Length of the associated data. @param plain Pointer to `plain_len` bytes of memory where the to-be-encrypted plaintext is read from. @param plain_len Length of the to-be-encrypted plaintext. @param cipher Pointer to `plain_len` bytes of memory where the ciphertext is written to. @param tag Pointer to `TAG_LEN` bytes of memory where the tag is written to. The length of the `tag` must be of a suitable length for the chosen algorithm: * `Spec_Agile_AEAD_AES128_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_AES256_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_CHACHA20_POLY1305` (TAG_LEN=16) @return `EverCrypt_AEAD_encrypt` may return either `EverCrypt_Error_Success` or `EverCrypt_Error_InvalidKey` (`EverCrypt_error.h`). The latter is returned if and only if the `s` parameter is `NULL`."] val encrypt: #a:G.erased (supported_alg) -> encrypt_st (G.reveal a) /// Encryption (no pre-allocated state) /// ----------------------------------- /// /// All-in-one API that does not require performing key expansion separately. /// Use if you must be in the Stack effect, or if you know you do not intend to /// reuse the key with a different nonce later. inline_for_extraction noextract let encrypt_expand_pre (a: supported_alg) (k:B.buffer uint8 { B.length k = key_length a }) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem)
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val encrypt_expand_pre : a: Spec.Agile.AEAD.supported_alg -> k: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 {LowStar.Monotonic.Buffer.length k = Spec.Agile.AEAD.key_length a} -> iv: EverCrypt.AEAD.iv_p a -> iv_len: FStar.UInt32.t -> ad: EverCrypt.AEAD.ad_p a -> ad_len: FStar.UInt32.t -> plain: EverCrypt.AEAD.plain_p a -> plain_len: FStar.UInt32.t -> cipher: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> tag: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> h0: FStar.Monotonic.HyperStack.mem -> Prims.logical
[]
EverCrypt.AEAD.encrypt_expand_pre
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.supported_alg -> k: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 {LowStar.Monotonic.Buffer.length k = Spec.Agile.AEAD.key_length a} -> iv: EverCrypt.AEAD.iv_p a -> iv_len: FStar.UInt32.t -> ad: EverCrypt.AEAD.ad_p a -> ad_len: FStar.UInt32.t -> plain: EverCrypt.AEAD.plain_p a -> plain_len: FStar.UInt32.t -> cipher: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> tag: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> h0: FStar.Monotonic.HyperStack.mem -> Prims.logical
{ "end_col": 58, "end_line": 383, "start_col": 2, "start_line": 380 }
FStar.Pervasives.Lemma
val loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires (B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s))) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))]
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s)
val loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires (B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s))) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires (B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s))) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] =
false
null
true
B.loc_includes_union_l l1 l2 (footprint_s s)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "lemma" ]
[ "LowStar.Monotonic.Buffer.loc", "Spec.Agile.AEAD.alg", "EverCrypt.AEAD.state_s", "LowStar.Monotonic.Buffer.loc_includes_union_l", "EverCrypt.AEAD.footprint_s", "Prims.unit", "Prims.l_or", "LowStar.Monotonic.Buffer.loc_includes", "Prims.squash", "LowStar.Monotonic.Buffer.loc_union", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s)))
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires (B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s))) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))]
[]
EverCrypt.AEAD.loc_includes_union_l_footprint_s
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l1: LowStar.Monotonic.Buffer.loc -> l2: LowStar.Monotonic.Buffer.loc -> s: EverCrypt.AEAD.state_s a -> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.loc_includes l1 (EverCrypt.AEAD.footprint_s s) \/ LowStar.Monotonic.Buffer.loc_includes l2 (EverCrypt.AEAD.footprint_s s)) (ensures LowStar.Monotonic.Buffer.loc_includes (LowStar.Monotonic.Buffer.loc_union l1 l2) (EverCrypt.AEAD.footprint_s s)) [ SMTPat (LowStar.Monotonic.Buffer.loc_includes (LowStar.Monotonic.Buffer.loc_union l1 l2) (EverCrypt.AEAD.footprint_s s)) ]
{ "end_col": 46, "end_line": 82, "start_col": 2, "start_line": 82 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0)
let invariant (#a: alg) (m: HS.mem) (s: state a) =
false
null
false
B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.alg", "FStar.Monotonic.HyperStack.mem", "EverCrypt.AEAD.state", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "EverCrypt.AEAD.state_s", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "EverCrypt.AEAD.footprint_s", "LowStar.Monotonic.Buffer.deref", "EverCrypt.AEAD.invariant_s", "LowStar.Monotonic.Buffer.get", "Prims.logical" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val invariant : m: FStar.Monotonic.HyperStack.mem -> s: EverCrypt.AEAD.state a -> Prims.logical
[]
EverCrypt.AEAD.invariant
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: FStar.Monotonic.HyperStack.mem -> s: EverCrypt.AEAD.state a -> Prims.logical
{ "end_col": 29, "end_line": 103, "start_col": 2, "start_line": 101 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let encrypt_gen_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = v iv_len = B.length iv /\ v iv_len > 0 /\ v ad_len = B.length ad /\ v ad_len <= pow2 31 /\ v plain_len = B.length plain /\ v plain_len <= max_length a /\ B.length cipher = B.length plain /\ B.length tag = tag_length a
let encrypt_gen_pre (a: supported_alg) (iv: iv_p a) (iv_len: UInt32.t) (ad: ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher tag: B.buffer uint8) (h0: HS.mem) =
false
null
false
v iv_len = B.length iv /\ v iv_len > 0 /\ v ad_len = B.length ad /\ v ad_len <= pow2 31 /\ v plain_len = B.length plain /\ v plain_len <= max_length a /\ B.length cipher = B.length plain /\ B.length tag = tag_length a
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "EverCrypt.AEAD.ad_p", "EverCrypt.AEAD.plain_p", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "FStar.Integers.op_Greater", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Integers.op_Less_Equals", "Prims.pow2", "Spec.Agile.AEAD.max_length", "Prims.nat", "Spec.Agile.AEAD.tag_length", "Prims.logical" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a } inline_for_extraction noextract let plain_p a = p:B.buffer uint8 { B.length p <= max_length a } inline_for_extraction noextract let cipher_p a = p:B.buffer uint8 { B.length p + tag_length a <= max_length a } // SNIPPET_START: encrypt_pre inline_for_extraction noextract let encrypt_gen_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem)
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val encrypt_gen_pre : a: Spec.Agile.AEAD.supported_alg -> iv: EverCrypt.AEAD.iv_p a -> iv_len: FStar.UInt32.t -> ad: EverCrypt.AEAD.ad_p a -> ad_len: FStar.UInt32.t -> plain: EverCrypt.AEAD.plain_p a -> plain_len: FStar.UInt32.t -> cipher: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> tag: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> h0: FStar.Monotonic.HyperStack.mem -> Prims.logical
[]
EverCrypt.AEAD.encrypt_gen_pre
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.supported_alg -> iv: EverCrypt.AEAD.iv_p a -> iv_len: FStar.UInt32.t -> ad: EverCrypt.AEAD.ad_p a -> ad_len: FStar.UInt32.t -> plain: EverCrypt.AEAD.plain_p a -> plain_len: FStar.UInt32.t -> cipher: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> tag: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> h0: FStar.Monotonic.HyperStack.mem -> Prims.logical
{ "end_col": 29, "end_line": 259, "start_col": 2, "start_line": 255 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False)
let create_in_st (a: alg) =
false
null
false
r: HS.rid -> dst: B.pointer (B.pointer_or_null (state_s a)) -> k: B.buffer uint8 {B.length k = key_length a} -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> let open B in modifies loc_none h0 h1 | Success -> let s = B.deref h1 dst in is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.alg", "FStar.Monotonic.HyperHeap.rid", "LowStar.Buffer.pointer", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.state_s", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "EverCrypt.Error.error_code", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.HyperStack.ST.is_eternal_region", "LowStar.Monotonic.Buffer.live", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Spec.Agile.AEAD.is_supported_alg", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "EverCrypt.AEAD.invariant", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Monotonic.Buffer.fresh_loc", "EverCrypt.AEAD.footprint", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.loc_region_only", "EverCrypt.AEAD.freeable", "Prims.eq2", "FStar.Seq.Base.seq", "EverCrypt.AEAD.as_kv", "LowStar.Monotonic.Buffer.deref", "LowStar.Monotonic.Buffer.as_seq", "Prims.l_False" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val create_in_st : a: Spec.Agile.AEAD.alg -> Type0
[]
EverCrypt.AEAD.create_in_st
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.alg -> Type0
{ "end_col": 19, "end_line": 174, "start_col": 2, "start_line": 148 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let encrypt_pre (a: supported_alg) (s:B.pointer_or_null (state_s a)) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer plain)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0)
let encrypt_pre (a: supported_alg) (s: B.pointer_or_null (state_s a)) (iv: iv_p a) (iv_len: UInt32.t) (ad: ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher tag: B.buffer uint8) (h0: HS.mem) =
false
null
false
encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ (not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer plain)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.state_s", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "EverCrypt.AEAD.ad_p", "EverCrypt.AEAD.plain_p", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverCrypt.AEAD.encrypt_gen_pre", "Prims.l_imp", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.trivial_preorder", "EverCrypt.AEAD.invariant", "LowStar.Monotonic.Buffer.loc_disjoint", "EverCrypt.AEAD.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "EverCrypt.AEAD.encrypt_live_disjoint_pre", "Prims.logical" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a } inline_for_extraction noextract let plain_p a = p:B.buffer uint8 { B.length p <= max_length a } inline_for_extraction noextract let cipher_p a = p:B.buffer uint8 { B.length p + tag_length a <= max_length a } // SNIPPET_START: encrypt_pre inline_for_extraction noextract let encrypt_gen_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = v iv_len = B.length iv /\ v iv_len > 0 /\ v ad_len = B.length ad /\ v ad_len <= pow2 31 /\ v plain_len = B.length plain /\ v plain_len <= max_length a /\ B.length cipher = B.length plain /\ B.length tag = tag_length a inline_for_extraction noextract let encrypt_live_disjoint_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = MB.(all_live h0 [ buf iv; buf ad; buf plain; buf cipher; buf tag ]) /\ (B.disjoint plain cipher \/ plain == cipher) /\ B.disjoint cipher tag /\ B.disjoint iv cipher /\ B.disjoint iv tag /\ B.disjoint plain tag /\ B.disjoint plain ad /\ B.disjoint ad cipher /\ B.disjoint ad tag inline_for_extraction noextract let encrypt_pre (a: supported_alg) (s:B.pointer_or_null (state_s a)) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem)
false
false
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val encrypt_pre : a: Spec.Agile.AEAD.supported_alg -> s: LowStar.Buffer.pointer_or_null (EverCrypt.AEAD.state_s a) -> iv: EverCrypt.AEAD.iv_p a -> iv_len: FStar.UInt32.t -> ad: EverCrypt.AEAD.ad_p a -> ad_len: FStar.UInt32.t -> plain: EverCrypt.AEAD.plain_p a -> plain_len: FStar.UInt32.t -> cipher: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> tag: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> h0: FStar.Monotonic.HyperStack.mem -> Prims.logical
[]
EverCrypt.AEAD.encrypt_pre
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.supported_alg -> s: LowStar.Buffer.pointer_or_null (EverCrypt.AEAD.state_s a) -> iv: EverCrypt.AEAD.iv_p a -> iv_len: FStar.UInt32.t -> ad: EverCrypt.AEAD.ad_p a -> ad_len: FStar.UInt32.t -> plain: EverCrypt.AEAD.plain_p a -> plain_len: FStar.UInt32.t -> cipher: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> tag: LowStar.Buffer.buffer Spec.Agile.AEAD.uint8 -> h0: FStar.Monotonic.HyperStack.mem -> Prims.logical
{ "end_col": 82, "end_line": 302, "start_col": 2, "start_line": 294 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let encrypt_expand_st (does_runtime_check: bool) (a: supported_alg) = k:B.buffer uint8 { B.length k = key_length a } -> iv:iv_p a -> iv_len: UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> plain: plain_p a -> plain_len: UInt32.t { v plain_len = B.length plain /\ v plain_len <= max_length a } -> cipher: B.buffer uint8 { B.length cipher = B.length plain } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> Stack error_code (requires fun h0 -> (if does_runtime_check then True else config_pre a) /\ encrypt_expand_pre a k iv iv_len ad ad_len plain plain_len cipher tag h0) (ensures fun h0 r h1 -> match r with | Success -> B.(modifies ((loc_union (loc_buffer cipher) (loc_buffer tag))) h0 h1) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (B.as_seq h0 k) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain)) | UnsupportedAlgorithm -> if does_runtime_check then B.(modifies loc_none h0 h1) else False | _ -> False)
let encrypt_expand_st (does_runtime_check: bool) (a: supported_alg) =
false
null
false
k: B.buffer uint8 {B.length k = key_length a} -> iv: iv_p a -> iv_len: UInt32.t{v iv_len = B.length iv /\ v iv_len > 0} -> ad: ad_p a -> ad_len: UInt32.t{v ad_len = B.length ad /\ v ad_len <= pow2 31} -> plain: plain_p a -> plain_len: UInt32.t{v plain_len = B.length plain /\ v plain_len <= max_length a} -> cipher: B.buffer uint8 {B.length cipher = B.length plain} -> tag: B.buffer uint8 {B.length tag = tag_length a} -> Stack error_code (requires fun h0 -> (if does_runtime_check then True else config_pre a) /\ encrypt_expand_pre a k iv iv_len ad ad_len plain plain_len cipher tag h0) (ensures fun h0 r h1 -> match r with | Success -> B.(modifies ((loc_union (loc_buffer cipher) (loc_buffer tag))) h0 h1) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (B.as_seq h0 k) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain) ) | UnsupportedAlgorithm -> if does_runtime_check then let open B in modifies loc_none h0 h1 else False | _ -> False)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Prims.bool", "Spec.Agile.AEAD.supported_alg", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "FStar.Integers.op_Greater", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.plain_p", "Spec.Agile.AEAD.max_length", "Prims.nat", "Spec.Agile.AEAD.tag_length", "EverCrypt.Error.error_code", "FStar.Monotonic.HyperStack.mem", "Prims.l_True", "EverCrypt.AEAD.config_pre", "Prims.logical", "EverCrypt.AEAD.encrypt_expand_pre", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_buffer", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "LowStar.Monotonic.Buffer.as_seq", "Spec.Agile.AEAD.encrypt", "LowStar.Monotonic.Buffer.loc_none", "Prims.l_False" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a } inline_for_extraction noextract let plain_p a = p:B.buffer uint8 { B.length p <= max_length a } inline_for_extraction noextract let cipher_p a = p:B.buffer uint8 { B.length p + tag_length a <= max_length a } // SNIPPET_START: encrypt_pre inline_for_extraction noextract let encrypt_gen_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = v iv_len = B.length iv /\ v iv_len > 0 /\ v ad_len = B.length ad /\ v ad_len <= pow2 31 /\ v plain_len = B.length plain /\ v plain_len <= max_length a /\ B.length cipher = B.length plain /\ B.length tag = tag_length a inline_for_extraction noextract let encrypt_live_disjoint_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = MB.(all_live h0 [ buf iv; buf ad; buf plain; buf cipher; buf tag ]) /\ (B.disjoint plain cipher \/ plain == cipher) /\ B.disjoint cipher tag /\ B.disjoint iv cipher /\ B.disjoint iv tag /\ B.disjoint plain tag /\ B.disjoint plain ad /\ B.disjoint ad cipher /\ B.disjoint ad tag inline_for_extraction noextract let encrypt_pre (a: supported_alg) (s:B.pointer_or_null (state_s a)) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer plain)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0) // SNIPPET_END: encrypt_pre inline_for_extraction noextract let encrypt_st (a: supported_alg) = s:B.pointer_or_null (state_s a) -> iv:iv_p a -> iv_len: UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> plain: plain_p a -> plain_len: UInt32.t { v plain_len = B.length plain /\ v plain_len <= max_length a } -> cipher: B.buffer uint8 { B.length cipher = B.length plain } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> Stack error_code (requires encrypt_pre a s iv iv_len ad ad_len plain plain_len cipher tag) (ensures fun h0 r h1 -> match r with | Success -> not (B.g_is_null s) /\ B.(modifies (loc_union (footprint h1 s) (loc_union (loc_buffer cipher) (loc_buffer tag))) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain)) | InvalidKey -> B.g_is_null s /\ B.(modifies loc_none h0 h1) | _ -> False) /// This function takes a previously expanded key and performs encryption. /// /// Possible return values are: /// - ``Success``: encryption was successfully performed /// - ``InvalidKey``: the function was passed a NULL expanded key (see above) (** @type: true *) [@@ Comment "Encrypt and authenticate a message (`plain`) with associated data (`ad`). @param s Pointer to the The AEAD state created by `EverCrypt_AEAD_create_in`. It already contains the encryption key. @param iv Pointer to `iv_len` bytes of memory where the nonce is read from. @param iv_len Length of the nonce. Note: ChaCha20Poly1305 requires a 12 byte nonce. @param ad Pointer to `ad_len` bytes of memory where the associated data is read from. @param ad_len Length of the associated data. @param plain Pointer to `plain_len` bytes of memory where the to-be-encrypted plaintext is read from. @param plain_len Length of the to-be-encrypted plaintext. @param cipher Pointer to `plain_len` bytes of memory where the ciphertext is written to. @param tag Pointer to `TAG_LEN` bytes of memory where the tag is written to. The length of the `tag` must be of a suitable length for the chosen algorithm: * `Spec_Agile_AEAD_AES128_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_AES256_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_CHACHA20_POLY1305` (TAG_LEN=16) @return `EverCrypt_AEAD_encrypt` may return either `EverCrypt_Error_Success` or `EverCrypt_Error_InvalidKey` (`EverCrypt_error.h`). The latter is returned if and only if the `s` parameter is `NULL`."] val encrypt: #a:G.erased (supported_alg) -> encrypt_st (G.reveal a) /// Encryption (no pre-allocated state) /// ----------------------------------- /// /// All-in-one API that does not require performing key expansion separately. /// Use if you must be in the Stack effect, or if you know you do not intend to /// reuse the key with a different nonce later. inline_for_extraction noextract let encrypt_expand_pre (a: supported_alg) (k:B.buffer uint8 { B.length k = key_length a }) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( B.live h0 k /\ B.disjoint k cipher /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0) inline_for_extraction noextract
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val encrypt_expand_st : does_runtime_check: Prims.bool -> a: Spec.Agile.AEAD.supported_alg -> Type0
[]
EverCrypt.AEAD.encrypt_expand_st
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
does_runtime_check: Prims.bool -> a: Spec.Agile.AEAD.supported_alg -> Type0
{ "end_col": 16, "end_line": 415, "start_col": 2, "start_line": 387 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let encrypt_st (a: supported_alg) = s:B.pointer_or_null (state_s a) -> iv:iv_p a -> iv_len: UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> plain: plain_p a -> plain_len: UInt32.t { v plain_len = B.length plain /\ v plain_len <= max_length a } -> cipher: B.buffer uint8 { B.length cipher = B.length plain } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> Stack error_code (requires encrypt_pre a s iv iv_len ad ad_len plain plain_len cipher tag) (ensures fun h0 r h1 -> match r with | Success -> not (B.g_is_null s) /\ B.(modifies (loc_union (footprint h1 s) (loc_union (loc_buffer cipher) (loc_buffer tag))) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain)) | InvalidKey -> B.g_is_null s /\ B.(modifies loc_none h0 h1) | _ -> False)
let encrypt_st (a: supported_alg) =
false
null
false
s: B.pointer_or_null (state_s a) -> iv: iv_p a -> iv_len: UInt32.t{v iv_len = B.length iv /\ v iv_len > 0} -> ad: ad_p a -> ad_len: UInt32.t{v ad_len = B.length ad /\ v ad_len <= pow2 31} -> plain: plain_p a -> plain_len: UInt32.t{v plain_len = B.length plain /\ v plain_len <= max_length a} -> cipher: B.buffer uint8 {B.length cipher = B.length plain} -> tag: B.buffer uint8 {B.length tag = tag_length a} -> Stack error_code (requires encrypt_pre a s iv iv_len ad ad_len plain plain_len cipher tag) (ensures fun h0 r h1 -> match r with | Success -> not (B.g_is_null s) /\ B.(modifies (loc_union (footprint h1 s) (loc_union (loc_buffer cipher) (loc_buffer tag)) ) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain)) | InvalidKey -> B.g_is_null s /\ B.(modifies loc_none h0 h1) | _ -> False)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.state_s", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "LowStar.Monotonic.Buffer.length", "Spec.Agile.AEAD.uint8", "LowStar.Buffer.trivial_preorder", "FStar.Integers.op_Greater", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.plain_p", "Spec.Agile.AEAD.max_length", "LowStar.Buffer.buffer", "Prims.nat", "Spec.Agile.AEAD.tag_length", "EverCrypt.Error.error_code", "EverCrypt.AEAD.encrypt_pre", "FStar.Monotonic.HyperStack.mem", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_union", "EverCrypt.AEAD.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "EverCrypt.AEAD.invariant", "Prims.eq2", "LowStar.Monotonic.Buffer.loc", "EverCrypt.AEAD.preserves_freeable", "Spec.Agile.AEAD.kv", "EverCrypt.AEAD.as_kv", "LowStar.Monotonic.Buffer.deref", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "LowStar.Monotonic.Buffer.as_seq", "Spec.Agile.AEAD.encrypt", "LowStar.Monotonic.Buffer.loc_none", "Prims.l_False" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a } inline_for_extraction noextract let plain_p a = p:B.buffer uint8 { B.length p <= max_length a } inline_for_extraction noextract let cipher_p a = p:B.buffer uint8 { B.length p + tag_length a <= max_length a } // SNIPPET_START: encrypt_pre inline_for_extraction noextract let encrypt_gen_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = v iv_len = B.length iv /\ v iv_len > 0 /\ v ad_len = B.length ad /\ v ad_len <= pow2 31 /\ v plain_len = B.length plain /\ v plain_len <= max_length a /\ B.length cipher = B.length plain /\ B.length tag = tag_length a inline_for_extraction noextract let encrypt_live_disjoint_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = MB.(all_live h0 [ buf iv; buf ad; buf plain; buf cipher; buf tag ]) /\ (B.disjoint plain cipher \/ plain == cipher) /\ B.disjoint cipher tag /\ B.disjoint iv cipher /\ B.disjoint iv tag /\ B.disjoint plain tag /\ B.disjoint plain ad /\ B.disjoint ad cipher /\ B.disjoint ad tag inline_for_extraction noextract let encrypt_pre (a: supported_alg) (s:B.pointer_or_null (state_s a)) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer plain)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0) // SNIPPET_END: encrypt_pre inline_for_extraction noextract
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val encrypt_st : a: Spec.Agile.AEAD.supported_alg -> Type0
[]
EverCrypt.AEAD.encrypt_st
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.supported_alg -> Type0
{ "end_col": 19, "end_line": 333, "start_col": 2, "start_line": 308 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decrypt_expand_st (does_runtime_check: bool) (a: supported_alg) = k:B.buffer uint8 { B.length k = key_length a } -> iv:iv_p a -> iv_len:UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> cipher: cipher_p a -> cipher_len: UInt32.t { v cipher_len = B.length cipher } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> dst: B.buffer uint8 { B.length dst = B.length cipher } -> Stack error_code (requires fun h0 -> (if does_runtime_check then True else config_pre a) /\ MB.(all_live h0 [ buf k; buf iv; buf ad; buf cipher; buf tag; buf dst ]) /\ B.disjoint k dst /\ B.disjoint tag dst /\ B.disjoint tag cipher /\ B.disjoint tag ad /\ B.disjoint cipher ad /\ B.disjoint dst ad /\ (B.disjoint cipher dst \/ cipher == dst)) (ensures fun h0 err h1 -> let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in let plain = Spec.decrypt #a (B.as_seq h0 k) (B.as_seq h0 iv) (B.as_seq h0 ad) cipher_tag in B.(modifies (loc_buffer dst) h0 h1) /\ begin match err with | Success -> Some? plain /\ S.equal (Some?.v plain) (B.as_seq h1 dst) | AuthenticationFailure -> None? plain | UnsupportedAlgorithm -> if does_runtime_check then B.(modifies loc_none h0 h1) else False | _ -> False end)
let decrypt_expand_st (does_runtime_check: bool) (a: supported_alg) =
false
null
false
k: B.buffer uint8 {B.length k = key_length a} -> iv: iv_p a -> iv_len: UInt32.t{v iv_len = B.length iv /\ v iv_len > 0} -> ad: ad_p a -> ad_len: UInt32.t{v ad_len = B.length ad /\ v ad_len <= pow2 31} -> cipher: cipher_p a -> cipher_len: UInt32.t{v cipher_len = B.length cipher} -> tag: B.buffer uint8 {B.length tag = tag_length a} -> dst: B.buffer uint8 {B.length dst = B.length cipher} -> Stack error_code (requires fun h0 -> (if does_runtime_check then True else config_pre a) /\ MB.(all_live h0 [buf k; buf iv; buf ad; buf cipher; buf tag; buf dst]) /\ B.disjoint k dst /\ B.disjoint tag dst /\ B.disjoint tag cipher /\ B.disjoint tag ad /\ B.disjoint cipher ad /\ B.disjoint dst ad /\ (B.disjoint cipher dst \/ cipher == dst)) (ensures fun h0 err h1 -> let cipher_tag = (B.as_seq h0 cipher) `S.append` (B.as_seq h0 tag) in let plain = Spec.decrypt #a (B.as_seq h0 k) (B.as_seq h0 iv) (B.as_seq h0 ad) cipher_tag in B.(modifies (loc_buffer dst) h0 h1) /\ (match err with | Success -> Some? plain /\ S.equal (Some?.v plain) (B.as_seq h1 dst) | AuthenticationFailure -> None? plain | UnsupportedAlgorithm -> if does_runtime_check then let open B in modifies loc_none h0 h1 else False | _ -> False))
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Prims.bool", "Spec.Agile.AEAD.supported_alg", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.op_Greater_Equals", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Spec.Agile.AEAD.key_length", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "FStar.Integers.op_Greater", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.cipher_p", "Spec.Agile.AEAD.tag_length", "Prims.nat", "EverCrypt.Error.error_code", "FStar.Monotonic.HyperStack.mem", "Prims.l_True", "EverCrypt.AEAD.config_pre", "Prims.logical", "LowStar.Monotonic.Buffer.all_live", "Prims.Cons", "LowStar.Monotonic.Buffer.buf_t", "LowStar.Monotonic.Buffer.buf", "Prims.Nil", "LowStar.Monotonic.Buffer.disjoint", "Prims.eq2", "FStar.Integers.op_Plus", "Spec.Agile.AEAD.max_length", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_buffer", "FStar.Pervasives.Native.uu___is_Some", "Spec.Agile.AEAD.decrypted", "FStar.Seq.Base.equal", "FStar.Pervasives.Native.__proj__Some__item__v", "LowStar.Monotonic.Buffer.as_seq", "FStar.Pervasives.Native.uu___is_None", "LowStar.Monotonic.Buffer.loc_none", "Prims.l_False", "FStar.Pervasives.Native.option", "Spec.Agile.AEAD.decrypt", "FStar.Seq.Base.seq", "FStar.Seq.Base.append" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a } inline_for_extraction noextract let plain_p a = p:B.buffer uint8 { B.length p <= max_length a } inline_for_extraction noextract let cipher_p a = p:B.buffer uint8 { B.length p + tag_length a <= max_length a } // SNIPPET_START: encrypt_pre inline_for_extraction noextract let encrypt_gen_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = v iv_len = B.length iv /\ v iv_len > 0 /\ v ad_len = B.length ad /\ v ad_len <= pow2 31 /\ v plain_len = B.length plain /\ v plain_len <= max_length a /\ B.length cipher = B.length plain /\ B.length tag = tag_length a inline_for_extraction noextract let encrypt_live_disjoint_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = MB.(all_live h0 [ buf iv; buf ad; buf plain; buf cipher; buf tag ]) /\ (B.disjoint plain cipher \/ plain == cipher) /\ B.disjoint cipher tag /\ B.disjoint iv cipher /\ B.disjoint iv tag /\ B.disjoint plain tag /\ B.disjoint plain ad /\ B.disjoint ad cipher /\ B.disjoint ad tag inline_for_extraction noextract let encrypt_pre (a: supported_alg) (s:B.pointer_or_null (state_s a)) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer plain)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0) // SNIPPET_END: encrypt_pre inline_for_extraction noextract let encrypt_st (a: supported_alg) = s:B.pointer_or_null (state_s a) -> iv:iv_p a -> iv_len: UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> plain: plain_p a -> plain_len: UInt32.t { v plain_len = B.length plain /\ v plain_len <= max_length a } -> cipher: B.buffer uint8 { B.length cipher = B.length plain } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> Stack error_code (requires encrypt_pre a s iv iv_len ad ad_len plain plain_len cipher tag) (ensures fun h0 r h1 -> match r with | Success -> not (B.g_is_null s) /\ B.(modifies (loc_union (footprint h1 s) (loc_union (loc_buffer cipher) (loc_buffer tag))) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain)) | InvalidKey -> B.g_is_null s /\ B.(modifies loc_none h0 h1) | _ -> False) /// This function takes a previously expanded key and performs encryption. /// /// Possible return values are: /// - ``Success``: encryption was successfully performed /// - ``InvalidKey``: the function was passed a NULL expanded key (see above) (** @type: true *) [@@ Comment "Encrypt and authenticate a message (`plain`) with associated data (`ad`). @param s Pointer to the The AEAD state created by `EverCrypt_AEAD_create_in`. It already contains the encryption key. @param iv Pointer to `iv_len` bytes of memory where the nonce is read from. @param iv_len Length of the nonce. Note: ChaCha20Poly1305 requires a 12 byte nonce. @param ad Pointer to `ad_len` bytes of memory where the associated data is read from. @param ad_len Length of the associated data. @param plain Pointer to `plain_len` bytes of memory where the to-be-encrypted plaintext is read from. @param plain_len Length of the to-be-encrypted plaintext. @param cipher Pointer to `plain_len` bytes of memory where the ciphertext is written to. @param tag Pointer to `TAG_LEN` bytes of memory where the tag is written to. The length of the `tag` must be of a suitable length for the chosen algorithm: * `Spec_Agile_AEAD_AES128_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_AES256_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_CHACHA20_POLY1305` (TAG_LEN=16) @return `EverCrypt_AEAD_encrypt` may return either `EverCrypt_Error_Success` or `EverCrypt_Error_InvalidKey` (`EverCrypt_error.h`). The latter is returned if and only if the `s` parameter is `NULL`."] val encrypt: #a:G.erased (supported_alg) -> encrypt_st (G.reveal a) /// Encryption (no pre-allocated state) /// ----------------------------------- /// /// All-in-one API that does not require performing key expansion separately. /// Use if you must be in the Stack effect, or if you know you do not intend to /// reuse the key with a different nonce later. inline_for_extraction noextract let encrypt_expand_pre (a: supported_alg) (k:B.buffer uint8 { B.length k = key_length a }) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( B.live h0 k /\ B.disjoint k cipher /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0) inline_for_extraction noextract let encrypt_expand_st (does_runtime_check: bool) (a: supported_alg) = k:B.buffer uint8 { B.length k = key_length a } -> iv:iv_p a -> iv_len: UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> plain: plain_p a -> plain_len: UInt32.t { v plain_len = B.length plain /\ v plain_len <= max_length a } -> cipher: B.buffer uint8 { B.length cipher = B.length plain } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> Stack error_code (requires fun h0 -> (if does_runtime_check then True else config_pre a) /\ encrypt_expand_pre a k iv iv_len ad ad_len plain plain_len cipher tag h0) (ensures fun h0 r h1 -> match r with | Success -> B.(modifies ((loc_union (loc_buffer cipher) (loc_buffer tag))) h0 h1) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (B.as_seq h0 k) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain)) | UnsupportedAlgorithm -> if does_runtime_check then B.(modifies loc_none h0 h1) else False | _ -> False) /// It's a little difficult to deal with AES-GCM cleanly because we're missing a /// fallback C implementation. The two functions below guard the reference to the /// X64 AES-GCM code behind a test of `EverCrypt.TargetConfig.hacl_can_compile_vale`, /// which gets extracted to a preprocessor test, so that we can always compile them. /// In case the code is compiled on a system which doesn't support Vale, the functions /// are compiled in such a way that they make the program exit cleanly. [@@ Comment "WARNING: this function doesn't perform any dynamic hardware check. You MUST make sure your hardware supports the implementation of AESGCM. Besides, this function was not designed for cross-compilation: if you compile it on a system which doesn't support Vale, it will compile it to a function which makes the program exit."] val encrypt_expand_aes128_gcm_no_check: encrypt_expand_st false AES128_GCM [@@ Comment "WARNING: this function doesn't perform any dynamic hardware check. You MUST make sure your hardware supports the implementation of AESGCM. Besides, this function was not designed for cross-compilation: if you compile it on a system which doesn't support Vale, it will compile it to a function which makes the program exit."] val encrypt_expand_aes256_gcm_no_check: encrypt_expand_st false AES256_GCM /// Those functions take a key, expand it then perform encryption. They do not /// require calling create_in before. val encrypt_expand_aes128_gcm: encrypt_expand_st true AES128_GCM val encrypt_expand_aes256_gcm: encrypt_expand_st true AES256_GCM val encrypt_expand_chacha20_poly1305: encrypt_expand_st false CHACHA20_POLY1305 /// Run-time agility, run-time multiplexing, but not pre-expansion of the key. val encrypt_expand: #a:supported_alg -> encrypt_expand_st true (G.reveal a) /// Decryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let decrypt_st (a: supported_alg) = s:B.pointer_or_null (state_s a) -> iv:iv_p a -> iv_len:UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> cipher: cipher_p a -> cipher_len: UInt32.t { v cipher_len = B.length cipher } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> dst: B.buffer uint8 { B.length dst = B.length cipher } -> Stack error_code (requires fun h0 -> not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer dst)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ MB.(all_live h0 [ buf iv; buf ad; buf cipher; buf tag; buf dst ]) /\ B.disjoint tag dst /\ B.disjoint tag cipher /\ B.disjoint tag ad /\ B.disjoint cipher ad /\ B.disjoint dst ad /\ (B.disjoint cipher dst \/ cipher == dst)) (ensures fun h0 err h1 -> let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in match err with | InvalidKey -> B.g_is_null s /\ B.(modifies loc_none h0 h1) | Success -> not (B.g_is_null s) /\ ( let plain = Spec.decrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) cipher_tag in B.(modifies (loc_union (footprint h1 s) (loc_buffer dst)) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ Some? plain /\ S.equal (Some?.v plain) (B.as_seq h1 dst)) | AuthenticationFailure -> not (B.g_is_null s) /\ ( let plain = decrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) cipher_tag in B.(modifies (loc_union (footprint h1 s) (loc_buffer dst)) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ None? plain) | _ -> False) /// This function takes a previously expanded key and performs decryption. /// /// Possible return values are: /// - ``Success``: decryption was successfully performed /// - ``InvalidKey``: the function was passed a NULL expanded key (see above) /// - ``Failure``: cipher text could not be decrypted (e.g. tag mismatch) (** @type: true *) [@@ Comment "Verify the authenticity of `ad` || `cipher` and decrypt `cipher` into `dst`. @param s Pointer to the The AEAD state created by `EverCrypt_AEAD_create_in`. It already contains the encryption key. @param iv Pointer to `iv_len` bytes of memory where the nonce is read from. @param iv_len Length of the nonce. Note: ChaCha20Poly1305 requires a 12 byte nonce. @param ad Pointer to `ad_len` bytes of memory where the associated data is read from. @param ad_len Length of the associated data. @param cipher Pointer to `cipher_len` bytes of memory where the ciphertext is read from. @param cipher_len Length of the ciphertext. @param tag Pointer to `TAG_LEN` bytes of memory where the tag is read from. The length of the `tag` must be of a suitable length for the chosen algorithm: * `Spec_Agile_AEAD_AES128_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_AES256_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_CHACHA20_POLY1305` (TAG_LEN=16) @param dst Pointer to `cipher_len` bytes of memory where the decrypted plaintext will be written to. @return `EverCrypt_AEAD_decrypt` returns ... * `EverCrypt_Error_Success` ... on success and either of ... * `EverCrypt_Error_InvalidKey` (returned if and only if the `s` parameter is `NULL`), * `EverCrypt_Error_InvalidIVLength` (see note about requirements on IV size above), or * `EverCrypt_Error_AuthenticationFailure` (in case the ciphertext could not be authenticated, e.g., due to modifications) ... on failure (`EverCrypt_error.h`). Upon success, the plaintext will be written into `dst`."] val decrypt: #a:G.erased supported_alg -> decrypt_st (G.reveal a) /// Decryption (no pre-allocated state) /// ----------------------------------- inline_for_extraction noextract
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decrypt_expand_st : does_runtime_check: Prims.bool -> a: Spec.Agile.AEAD.supported_alg -> Type0
[]
EverCrypt.AEAD.decrypt_expand_st
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
does_runtime_check: Prims.bool -> a: Spec.Agile.AEAD.supported_alg -> Type0
{ "end_col": 10, "end_line": 586, "start_col": 2, "start_line": 549 }
Prims.Tot
[ { "abbrev": false, "full_module": "EverCrypt.Error", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "Spec" }, { "abbrev": false, "full_module": "Spec.Agile.AEAD", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decrypt_st (a: supported_alg) = s:B.pointer_or_null (state_s a) -> iv:iv_p a -> iv_len:UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> cipher: cipher_p a -> cipher_len: UInt32.t { v cipher_len = B.length cipher } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> dst: B.buffer uint8 { B.length dst = B.length cipher } -> Stack error_code (requires fun h0 -> not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer dst)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ MB.(all_live h0 [ buf iv; buf ad; buf cipher; buf tag; buf dst ]) /\ B.disjoint tag dst /\ B.disjoint tag cipher /\ B.disjoint tag ad /\ B.disjoint cipher ad /\ B.disjoint dst ad /\ (B.disjoint cipher dst \/ cipher == dst)) (ensures fun h0 err h1 -> let cipher_tag = B.as_seq h0 cipher `S.append` B.as_seq h0 tag in match err with | InvalidKey -> B.g_is_null s /\ B.(modifies loc_none h0 h1) | Success -> not (B.g_is_null s) /\ ( let plain = Spec.decrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) cipher_tag in B.(modifies (loc_union (footprint h1 s) (loc_buffer dst)) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ Some? plain /\ S.equal (Some?.v plain) (B.as_seq h1 dst)) | AuthenticationFailure -> not (B.g_is_null s) /\ ( let plain = decrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) cipher_tag in B.(modifies (loc_union (footprint h1 s) (loc_buffer dst)) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ None? plain) | _ -> False)
let decrypt_st (a: supported_alg) =
false
null
false
s: B.pointer_or_null (state_s a) -> iv: iv_p a -> iv_len: UInt32.t{v iv_len = B.length iv /\ v iv_len > 0} -> ad: ad_p a -> ad_len: UInt32.t{v ad_len = B.length ad /\ v ad_len <= pow2 31} -> cipher: cipher_p a -> cipher_len: UInt32.t{v cipher_len = B.length cipher} -> tag: B.buffer uint8 {B.length tag = tag_length a} -> dst: B.buffer uint8 {B.length dst = B.length cipher} -> Stack error_code (requires fun h0 -> not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer dst)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ MB.(all_live h0 [buf iv; buf ad; buf cipher; buf tag; buf dst]) /\ B.disjoint tag dst /\ B.disjoint tag cipher /\ B.disjoint tag ad /\ B.disjoint cipher ad /\ B.disjoint dst ad /\ (B.disjoint cipher dst \/ cipher == dst)) (ensures fun h0 err h1 -> let cipher_tag = (B.as_seq h0 cipher) `S.append` (B.as_seq h0 tag) in match err with | InvalidKey -> B.g_is_null s /\ B.(modifies loc_none h0 h1) | Success -> not (B.g_is_null s) /\ (let plain = Spec.decrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) cipher_tag in B.(modifies (loc_union (footprint h1 s) (loc_buffer dst)) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ Some? plain /\ S.equal (Some?.v plain) (B.as_seq h1 dst)) | AuthenticationFailure -> not (B.g_is_null s) /\ (let plain = decrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) cipher_tag in B.(modifies (loc_union (footprint h1 s) (loc_buffer dst)) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ None? plain) | _ -> False)
{ "checked_file": "EverCrypt.AEAD.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "EverCrypt.TargetConfig.fsti.checked", "EverCrypt.Error.fsti.checked" ], "interface_file": false, "source_file": "EverCrypt.AEAD.fsti" }
[ "total" ]
[ "Spec.Agile.AEAD.supported_alg", "LowStar.Buffer.pointer_or_null", "EverCrypt.AEAD.state_s", "EverCrypt.AEAD.iv_p", "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Integers.within_bounds", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.Integers.v", "LowStar.Monotonic.Buffer.length", "Spec.Agile.AEAD.uint8", "LowStar.Buffer.trivial_preorder", "FStar.Integers.op_Greater", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "EverCrypt.AEAD.ad_p", "FStar.Integers.op_Less_Equals", "Prims.pow2", "EverCrypt.AEAD.cipher_p", "LowStar.Buffer.buffer", "Spec.Agile.AEAD.tag_length", "Prims.nat", "EverCrypt.Error.error_code", "FStar.Monotonic.HyperStack.mem", "Prims.l_imp", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "EverCrypt.AEAD.invariant", "LowStar.Monotonic.Buffer.loc_disjoint", "EverCrypt.AEAD.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Monotonic.Buffer.all_live", "Prims.Cons", "LowStar.Monotonic.Buffer.buf_t", "LowStar.Monotonic.Buffer.buf", "Prims.Nil", "LowStar.Monotonic.Buffer.disjoint", "Prims.eq2", "FStar.Integers.op_Plus", "Spec.Agile.AEAD.max_length", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc", "EverCrypt.AEAD.preserves_freeable", "Spec.Agile.AEAD.kv", "EverCrypt.AEAD.as_kv", "LowStar.Monotonic.Buffer.deref", "FStar.Pervasives.Native.uu___is_Some", "Spec.Agile.AEAD.decrypted", "FStar.Seq.Base.equal", "FStar.Pervasives.Native.__proj__Some__item__v", "LowStar.Monotonic.Buffer.as_seq", "FStar.Pervasives.Native.option", "Spec.Agile.AEAD.decrypt", "FStar.Pervasives.Native.uu___is_None", "Prims.l_False", "FStar.Seq.Base.seq", "FStar.Seq.Base.append" ]
[]
module EverCrypt.AEAD /// The new AEAD interface for EverCrypt, which supersedes the functions found /// in EverCrypt.fst /// /// The expected usage for this module is as follows: /// - client expands key, obtaining an ``expanded_key a`` /// - client uses ``encrypt``/``decrypt`` with the same ``expanded_key a`` repeatedly. /// /// This usage protocol is enforced for verified F* clients but, naturally, /// isn't for C clients. module S = FStar.Seq module G = FStar.Ghost module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Integers open Spec.Agile.AEAD module Spec = Spec.Agile.AEAD open EverCrypt.Error /// Note: if the fst and the fsti are running on different fuel settings, /// something that works in the interactive mode for the fsti, when /// "re-interpreted" in the fst, might stop working! #set-options "--max_fuel 0 --max_ifuel 0" /// Abstract footprints, with the same machinery as EverCrypt.Hash /// -------------------------------------------------------------- /// /// Differences from EverCrypt.Hash include: combined framing lemma, the /// equivalent of the ``repr`` function does *not* require the memory, and order /// of arguments to be in line with ``B.as_seq``, etc. which take the memory /// first. [@@ CAbstractStruct; Comment "Both encryption and decryption require a state that holds the key. The state may be reused as many times as desired."] val state_s: alg -> Type0 inline_for_extraction noextract let state alg = B.pointer (state_s alg) inline_for_extraction noextract val freeable_s: #(a: alg) -> state_s a -> Type0 inline_for_extraction noextract let freeable (#a: alg) (h: HS.mem) (p: state a) = B.freeable p /\ freeable_s (B.deref h p) inline_for_extraction noextract let preserves_freeable #a (s: state a) (h0 h1: HS.mem): Type0 = freeable h0 s ==> freeable h1 s val footprint_s: #a:alg -> state_s a -> GTot B.loc let footprint (#a:alg) (m: HS.mem) (s: state a) = B.(loc_union (loc_addr_of_buffer s) (footprint_s (B.deref m s))) // TR: the following pattern is necessary because, if we generically // add such a pattern directly on `loc_includes_union_l`, then // verification will blowup whenever both sides of `loc_includes` are // `loc_union`s. We would like to break all unions on the // right-hand-side of `loc_includes` first, using // `loc_includes_union_r`. Here the pattern is on `footprint_s`, // because we already expose the fact that `footprint` is a // `loc_union`. (In other words, the pattern should be on every // smallest location that is not exposed to be a `loc_union`.) let loc_includes_union_l_footprint_s (l1 l2: B.loc) (#a: alg) (s: state_s a) : Lemma (requires ( B.loc_includes l1 (footprint_s s) \/ B.loc_includes l2 (footprint_s s) )) (ensures (B.loc_includes (B.loc_union l1 l2) (footprint_s s))) [SMTPat (B.loc_includes (B.loc_union l1 l2) (footprint_s s))] = B.loc_includes_union_l l1 l2 (footprint_s s) /// The configuration preconditions inline_for_extraction noextract let config_pre a = match a with | AES128_GCM | AES256_GCM -> EverCrypt.TargetConfig.hacl_can_compile_vale /\ Vale.X64.CPU_Features_s.(aesni_enabled /\ pclmulqdq_enabled /\ avx_enabled /\ movbe_enabled /\ sse_enabled) | CHACHA20_POLY1305 -> True | _ -> True inline_for_extraction noextract val invariant_s: (#a:alg) -> HS.mem -> state_s a -> Type0 inline_for_extraction noextract let invariant (#a:alg) (m: HS.mem) (s: state a) = B.live m s /\ B.(loc_disjoint (loc_addr_of_buffer s) (footprint_s (B.deref m s))) /\ invariant_s m (B.get m s 0) val invariant_loc_in_footprint (#a: alg) (s: state a) (m: HS.mem) : Lemma (requires (invariant m s)) (ensures (B.loc_in (footprint m s) m)) [SMTPat (invariant m s)] val frame_invariant: #a:alg -> l:B.loc -> s:state a -> h0:HS.mem -> h1:HS.mem -> Lemma (requires ( invariant h0 s /\ B.loc_disjoint l (footprint h0 s) /\ B.modifies l h0 h1)) (ensures ( invariant h1 s /\ footprint h0 s == footprint h1 s)) [ SMTPat (invariant h1 s); SMTPat (B.modifies l h0 h1) ] /// Actual stateful API /// ------------------- noextract let bytes = Seq.seq uint8 [@@ Comment "Return the algorithm used in the AEAD state. @param s State of the AEAD algorithm. @return Algorithm used in the AEAD state."] val alg_of_state (a: G.erased alg) (s: state (G.reveal a)): Stack alg (requires (fun h0 -> invariant #(G.reveal a) h0 s)) (ensures (fun h0 a' h1 -> a' == G.reveal a /\ h0 == h1)) /// The API is constructed in a way that one can always get the original key /// value behind a state, any any memory. val as_kv: (#a: alg) -> state_s a -> GTot (kv a) inline_for_extraction noextract let create_in_st (a: alg) = r:HS.rid -> dst:B.pointer (B.pointer_or_null (state_s a)) -> k:B.buffer uint8 { B.length k = key_length a } -> ST error_code (requires fun h0 -> ST.is_eternal_region r /\ B.live h0 k /\ B.live h0 dst) (ensures fun h0 e h1 -> match e with | UnsupportedAlgorithm -> B.(modifies loc_none h0 h1) | Success -> let s = B.deref h1 dst in // Sanity is_supported_alg a /\ not (B.g_is_null s) /\ invariant h1 s /\ // Memory stuff B.(modifies (loc_buffer dst) h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.(loc_includes (loc_region_only true r) (footprint h1 s)) /\ freeable h1 s /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k | _ -> False) /// Same function as above, but in the StackInline effect, so that it is possible /// to use AES GCM while staying in the Stack effect. In this case, the state should /// be allocated/deallocated just before/after any encryption or decryption (which /// is not very problematic during, for example, a handshake). inline_for_extraction noextract let alloca_st (a: alg) = k:B.buffer uint8 { B.length k = key_length a } -> StackInline (B.pointer (state_s a)) (requires fun h0 -> B.live h0 k /\ config_pre a /\ is_supported_alg a) (ensures fun h0 s h1 -> // Sanity invariant h1 s /\ // Memory stuff B.(modifies loc_none h0 h1) /\ B.fresh_loc (footprint h1 s) h0 h1 /\ B.live h1 s /\ B.(loc_includes (loc_region_only true (HS.get_tip h1)) (footprint h1 s)) /\ // Useful stuff as_kv (B.deref h1 s) == B.as_seq h0 k) /// This function takes a pointer to a caller-allocated reference ``dst`` then, /// if the algorithm is supported (on this platform), allocates a fresh state /// and modifies ``dst`` to point to it. The key-value associated with this can /// be obtained via ``kv (B.deref dst)``; as long as ``dst`` is not modified, /// then the caller can derive that the ``kv`` remains the same, which will be /// required for encrypt. (** @type: true *) [@@ Comment "Create the required AEAD state for the algorithm. Note: The caller must free the AEAD state by calling `EverCrypt_AEAD_free`. @param a The argument `a` must be either of: * `Spec_Agile_AEAD_AES128_GCM` (KEY_LEN=16), * `Spec_Agile_AEAD_AES256_GCM` (KEY_LEN=32), or * `Spec_Agile_AEAD_CHACHA20_POLY1305` (KEY_LEN=32). @param dst Pointer to a pointer where the address of the allocated AEAD state will be written to. @param k Pointer to `KEY_LEN` bytes of memory where the key is read from. The size depends on the used algorithm, see above. @return The function returns `EverCrypt_Error_Success` on success or `EverCrypt_Error_UnsupportedAlgorithm` in case of a bad algorithm identifier. (See `EverCrypt_Error.h`.)"] val create_in: #a:alg -> create_in_st a inline_for_extraction noextract val alloca: #a:alg -> alloca_st a /// Encryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract let iv_p a = iv:B.buffer uint8 { iv_length a (B.length iv)} inline_for_extraction noextract let ad_p a = ad:B.buffer uint8 { B.length ad <= max_length a } inline_for_extraction noextract let plain_p a = p:B.buffer uint8 { B.length p <= max_length a } inline_for_extraction noextract let cipher_p a = p:B.buffer uint8 { B.length p + tag_length a <= max_length a } // SNIPPET_START: encrypt_pre inline_for_extraction noextract let encrypt_gen_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = v iv_len = B.length iv /\ v iv_len > 0 /\ v ad_len = B.length ad /\ v ad_len <= pow2 31 /\ v plain_len = B.length plain /\ v plain_len <= max_length a /\ B.length cipher = B.length plain /\ B.length tag = tag_length a inline_for_extraction noextract let encrypt_live_disjoint_pre (a: supported_alg) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = MB.(all_live h0 [ buf iv; buf ad; buf plain; buf cipher; buf tag ]) /\ (B.disjoint plain cipher \/ plain == cipher) /\ B.disjoint cipher tag /\ B.disjoint iv cipher /\ B.disjoint iv tag /\ B.disjoint plain tag /\ B.disjoint plain ad /\ B.disjoint ad cipher /\ B.disjoint ad tag inline_for_extraction noextract let encrypt_pre (a: supported_alg) (s:B.pointer_or_null (state_s a)) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( not (B.g_is_null s) ==> invariant h0 s /\ B.(loc_disjoint (footprint h0 s) (loc_buffer iv)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer ad)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer tag)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer plain)) /\ B.(loc_disjoint (footprint h0 s) (loc_buffer cipher)) /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0) // SNIPPET_END: encrypt_pre inline_for_extraction noextract let encrypt_st (a: supported_alg) = s:B.pointer_or_null (state_s a) -> iv:iv_p a -> iv_len: UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> plain: plain_p a -> plain_len: UInt32.t { v plain_len = B.length plain /\ v plain_len <= max_length a } -> cipher: B.buffer uint8 { B.length cipher = B.length plain } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> Stack error_code (requires encrypt_pre a s iv iv_len ad ad_len plain plain_len cipher tag) (ensures fun h0 r h1 -> match r with | Success -> not (B.g_is_null s) /\ B.(modifies (loc_union (footprint h1 s) (loc_union (loc_buffer cipher) (loc_buffer tag))) h0 h1) /\ invariant h1 s /\ footprint h0 s == footprint h1 s /\ preserves_freeable s h0 h1 /\ as_kv (B.deref h1 s) == as_kv (B.deref h0 s) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (as_kv (B.deref h0 s)) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain)) | InvalidKey -> B.g_is_null s /\ B.(modifies loc_none h0 h1) | _ -> False) /// This function takes a previously expanded key and performs encryption. /// /// Possible return values are: /// - ``Success``: encryption was successfully performed /// - ``InvalidKey``: the function was passed a NULL expanded key (see above) (** @type: true *) [@@ Comment "Encrypt and authenticate a message (`plain`) with associated data (`ad`). @param s Pointer to the The AEAD state created by `EverCrypt_AEAD_create_in`. It already contains the encryption key. @param iv Pointer to `iv_len` bytes of memory where the nonce is read from. @param iv_len Length of the nonce. Note: ChaCha20Poly1305 requires a 12 byte nonce. @param ad Pointer to `ad_len` bytes of memory where the associated data is read from. @param ad_len Length of the associated data. @param plain Pointer to `plain_len` bytes of memory where the to-be-encrypted plaintext is read from. @param plain_len Length of the to-be-encrypted plaintext. @param cipher Pointer to `plain_len` bytes of memory where the ciphertext is written to. @param tag Pointer to `TAG_LEN` bytes of memory where the tag is written to. The length of the `tag` must be of a suitable length for the chosen algorithm: * `Spec_Agile_AEAD_AES128_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_AES256_GCM` (TAG_LEN=16) * `Spec_Agile_AEAD_CHACHA20_POLY1305` (TAG_LEN=16) @return `EverCrypt_AEAD_encrypt` may return either `EverCrypt_Error_Success` or `EverCrypt_Error_InvalidKey` (`EverCrypt_error.h`). The latter is returned if and only if the `s` parameter is `NULL`."] val encrypt: #a:G.erased (supported_alg) -> encrypt_st (G.reveal a) /// Encryption (no pre-allocated state) /// ----------------------------------- /// /// All-in-one API that does not require performing key expansion separately. /// Use if you must be in the Stack effect, or if you know you do not intend to /// reuse the key with a different nonce later. inline_for_extraction noextract let encrypt_expand_pre (a: supported_alg) (k:B.buffer uint8 { B.length k = key_length a }) (iv:iv_p a) (iv_len: UInt32.t) (ad:ad_p a) (ad_len: UInt32.t) (plain: plain_p a) (plain_len: UInt32.t) (cipher: B.buffer uint8) (tag: B.buffer uint8) (h0: HS.mem) = encrypt_gen_pre a iv iv_len ad ad_len plain plain_len cipher tag h0 /\ ( B.live h0 k /\ B.disjoint k cipher /\ encrypt_live_disjoint_pre a iv iv_len ad ad_len plain plain_len cipher tag h0) inline_for_extraction noextract let encrypt_expand_st (does_runtime_check: bool) (a: supported_alg) = k:B.buffer uint8 { B.length k = key_length a } -> iv:iv_p a -> iv_len: UInt32.t { v iv_len = B.length iv /\ v iv_len > 0 } -> ad:ad_p a -> ad_len: UInt32.t { v ad_len = B.length ad /\ v ad_len <= pow2 31 } -> plain: plain_p a -> plain_len: UInt32.t { v plain_len = B.length plain /\ v plain_len <= max_length a } -> cipher: B.buffer uint8 { B.length cipher = B.length plain } -> tag: B.buffer uint8 { B.length tag = tag_length a } -> Stack error_code (requires fun h0 -> (if does_runtime_check then True else config_pre a) /\ encrypt_expand_pre a k iv iv_len ad ad_len plain plain_len cipher tag h0) (ensures fun h0 r h1 -> match r with | Success -> B.(modifies ((loc_union (loc_buffer cipher) (loc_buffer tag))) h0 h1) /\ S.equal (S.append (B.as_seq h1 cipher) (B.as_seq h1 tag)) (Spec.encrypt #a (B.as_seq h0 k) (B.as_seq h0 iv) (B.as_seq h0 ad) (B.as_seq h0 plain)) | UnsupportedAlgorithm -> if does_runtime_check then B.(modifies loc_none h0 h1) else False | _ -> False) /// It's a little difficult to deal with AES-GCM cleanly because we're missing a /// fallback C implementation. The two functions below guard the reference to the /// X64 AES-GCM code behind a test of `EverCrypt.TargetConfig.hacl_can_compile_vale`, /// which gets extracted to a preprocessor test, so that we can always compile them. /// In case the code is compiled on a system which doesn't support Vale, the functions /// are compiled in such a way that they make the program exit cleanly. [@@ Comment "WARNING: this function doesn't perform any dynamic hardware check. You MUST make sure your hardware supports the implementation of AESGCM. Besides, this function was not designed for cross-compilation: if you compile it on a system which doesn't support Vale, it will compile it to a function which makes the program exit."] val encrypt_expand_aes128_gcm_no_check: encrypt_expand_st false AES128_GCM [@@ Comment "WARNING: this function doesn't perform any dynamic hardware check. You MUST make sure your hardware supports the implementation of AESGCM. Besides, this function was not designed for cross-compilation: if you compile it on a system which doesn't support Vale, it will compile it to a function which makes the program exit."] val encrypt_expand_aes256_gcm_no_check: encrypt_expand_st false AES256_GCM /// Those functions take a key, expand it then perform encryption. They do not /// require calling create_in before. val encrypt_expand_aes128_gcm: encrypt_expand_st true AES128_GCM val encrypt_expand_aes256_gcm: encrypt_expand_st true AES256_GCM val encrypt_expand_chacha20_poly1305: encrypt_expand_st false CHACHA20_POLY1305 /// Run-time agility, run-time multiplexing, but not pre-expansion of the key. val encrypt_expand: #a:supported_alg -> encrypt_expand_st true (G.reveal a) /// Decryption (pre-allocated state) /// -------------------------------- inline_for_extraction noextract
false
true
EverCrypt.AEAD.fsti
{ "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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decrypt_st : a: Spec.Agile.AEAD.supported_alg -> Type0
[]
EverCrypt.AEAD.decrypt_st
{ "file_name": "providers/evercrypt/EverCrypt.AEAD.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.AEAD.supported_alg -> Type0
{ "end_col": 16, "end_line": 502, "start_col": 2, "start_line": 454 }
Prims.Tot
val openBase: openBase_st cs vale_p
[ { "abbrev": true, "full_module": "Hacl.HPKE.Interface.AEAD", "short_module": "IAEAD" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.Hash", "short_module": "IHash" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.HKDF", "short_module": "IHK" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.DH", "short_module": "IDH" }, { "abbrev": false, "full_module": "Hacl.Meta.HPKE", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "AEAD" }, { "abbrev": true, "full_module": "Spec.Agile.DH", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let openBase = hpke_openBase_higher #cs vale_p IAEAD.aead_decrypt_cp256 setupBaseR
val openBase: openBase_st cs vale_p let openBase =
false
null
false
hpke_openBase_higher #cs vale_p IAEAD.aead_decrypt_cp256 setupBaseR
{ "checked_file": "Hacl.HPKE.Curve64_CP256_SHA256.fst.checked", "dependencies": [ "prims.fst.checked", "Hacl.Meta.HPKE.fst.checked", "Hacl.Meta.HPKE.fst.checked", "Hacl.HPKE.Interface.HKDF.fst.checked", "Hacl.HPKE.Interface.Hash.fst.checked", "Hacl.HPKE.Interface.DH.fst.checked", "Hacl.HPKE.Interface.AEAD.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Hacl.HPKE.Curve64_CP256_SHA256.fst" }
[ "total" ]
[ "Hacl.Meta.HPKE.hpke_openBase_higher", "Hacl.HPKE.Curve64_CP256_SHA256.cs", "Hacl.HPKE.Curve64_CP256_SHA256.vale_p", "Hacl.HPKE.Interface.AEAD.aead_decrypt_cp256", "Hacl.HPKE.Curve64_CP256_SHA256.setupBaseR" ]
[]
module Hacl.HPKE.Curve64_CP256_SHA256 open Hacl.Meta.HPKE module IDH = Hacl.HPKE.Interface.DH module IHK = Hacl.HPKE.Interface.HKDF module IHash = Hacl.HPKE.Interface.Hash module IAEAD = Hacl.HPKE.Interface.AEAD friend Hacl.Meta.HPKE #set-options "--fuel 0 --ifuel 0" let setupBaseS = hpke_setupBaseS_higher #cs vale_p IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 let setupBaseR = hpke_setupBaseR_higher #cs vale_p IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64 let sealBase = hpke_sealBase_higher #cs vale_p IAEAD.aead_encrypt_cp256 setupBaseS
false
true
Hacl.HPKE.Curve64_CP256_SHA256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val openBase: openBase_st cs vale_p
[]
Hacl.HPKE.Curve64_CP256_SHA256.openBase
{ "file_name": "code/hpke/Hacl.HPKE.Curve64_CP256_SHA256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.HPKE.openBase_st Hacl.HPKE.Curve64_CP256_SHA256.cs Hacl.HPKE.Curve64_CP256_SHA256.vale_p
{ "end_col": 82, "end_line": 20, "start_col": 15, "start_line": 20 }
Prims.Tot
val sealBase: sealBase_st cs vale_p
[ { "abbrev": true, "full_module": "Hacl.HPKE.Interface.AEAD", "short_module": "IAEAD" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.Hash", "short_module": "IHash" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.HKDF", "short_module": "IHK" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.DH", "short_module": "IDH" }, { "abbrev": false, "full_module": "Hacl.Meta.HPKE", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "AEAD" }, { "abbrev": true, "full_module": "Spec.Agile.DH", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sealBase = hpke_sealBase_higher #cs vale_p IAEAD.aead_encrypt_cp256 setupBaseS
val sealBase: sealBase_st cs vale_p let sealBase =
false
null
false
hpke_sealBase_higher #cs vale_p IAEAD.aead_encrypt_cp256 setupBaseS
{ "checked_file": "Hacl.HPKE.Curve64_CP256_SHA256.fst.checked", "dependencies": [ "prims.fst.checked", "Hacl.Meta.HPKE.fst.checked", "Hacl.Meta.HPKE.fst.checked", "Hacl.HPKE.Interface.HKDF.fst.checked", "Hacl.HPKE.Interface.Hash.fst.checked", "Hacl.HPKE.Interface.DH.fst.checked", "Hacl.HPKE.Interface.AEAD.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Hacl.HPKE.Curve64_CP256_SHA256.fst" }
[ "total" ]
[ "Hacl.Meta.HPKE.hpke_sealBase_higher", "Hacl.HPKE.Curve64_CP256_SHA256.cs", "Hacl.HPKE.Curve64_CP256_SHA256.vale_p", "Hacl.HPKE.Interface.AEAD.aead_encrypt_cp256", "Hacl.HPKE.Curve64_CP256_SHA256.setupBaseS" ]
[]
module Hacl.HPKE.Curve64_CP256_SHA256 open Hacl.Meta.HPKE module IDH = Hacl.HPKE.Interface.DH module IHK = Hacl.HPKE.Interface.HKDF module IHash = Hacl.HPKE.Interface.Hash module IAEAD = Hacl.HPKE.Interface.AEAD friend Hacl.Meta.HPKE #set-options "--fuel 0 --ifuel 0" let setupBaseS = hpke_setupBaseS_higher #cs vale_p IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 let setupBaseR = hpke_setupBaseR_higher #cs vale_p IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64
false
true
Hacl.HPKE.Curve64_CP256_SHA256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sealBase: sealBase_st cs vale_p
[]
Hacl.HPKE.Curve64_CP256_SHA256.sealBase
{ "file_name": "code/hpke/Hacl.HPKE.Curve64_CP256_SHA256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.HPKE.sealBase_st Hacl.HPKE.Curve64_CP256_SHA256.cs Hacl.HPKE.Curve64_CP256_SHA256.vale_p
{ "end_col": 82, "end_line": 18, "start_col": 15, "start_line": 18 }
Prims.Tot
val setupBaseS: setupBaseS_st cs vale_p
[ { "abbrev": true, "full_module": "Hacl.HPKE.Interface.AEAD", "short_module": "IAEAD" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.Hash", "short_module": "IHash" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.HKDF", "short_module": "IHK" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.DH", "short_module": "IDH" }, { "abbrev": false, "full_module": "Hacl.Meta.HPKE", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "AEAD" }, { "abbrev": true, "full_module": "Spec.Agile.DH", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let setupBaseS = hpke_setupBaseS_higher #cs vale_p IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256
val setupBaseS: setupBaseS_st cs vale_p let setupBaseS =
false
null
false
hpke_setupBaseS_higher #cs vale_p IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256
{ "checked_file": "Hacl.HPKE.Curve64_CP256_SHA256.fst.checked", "dependencies": [ "prims.fst.checked", "Hacl.Meta.HPKE.fst.checked", "Hacl.Meta.HPKE.fst.checked", "Hacl.HPKE.Interface.HKDF.fst.checked", "Hacl.HPKE.Interface.Hash.fst.checked", "Hacl.HPKE.Interface.DH.fst.checked", "Hacl.HPKE.Interface.AEAD.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Hacl.HPKE.Curve64_CP256_SHA256.fst" }
[ "total" ]
[ "Hacl.Meta.HPKE.hpke_setupBaseS_higher", "Hacl.HPKE.Curve64_CP256_SHA256.cs", "Hacl.HPKE.Curve64_CP256_SHA256.vale_p", "Hacl.HPKE.Interface.HKDF.hkdf_expand256", "Hacl.HPKE.Interface.HKDF.hkdf_extract256", "Hacl.HPKE.Interface.DH.secret_to_public_c64", "Hacl.HPKE.Interface.DH.dh_c64" ]
[]
module Hacl.HPKE.Curve64_CP256_SHA256 open Hacl.Meta.HPKE module IDH = Hacl.HPKE.Interface.DH module IHK = Hacl.HPKE.Interface.HKDF module IHash = Hacl.HPKE.Interface.Hash module IAEAD = Hacl.HPKE.Interface.AEAD friend Hacl.Meta.HPKE #set-options "--fuel 0 --ifuel 0"
false
true
Hacl.HPKE.Curve64_CP256_SHA256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val setupBaseS: setupBaseS_st cs vale_p
[]
Hacl.HPKE.Curve64_CP256_SHA256.setupBaseS
{ "file_name": "code/hpke/Hacl.HPKE.Curve64_CP256_SHA256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.HPKE.setupBaseS_st Hacl.HPKE.Curve64_CP256_SHA256.cs Hacl.HPKE.Curve64_CP256_SHA256.vale_p
{ "end_col": 164, "end_line": 14, "start_col": 17, "start_line": 14 }
Prims.Tot
val setupBaseR: setupBaseR_st cs vale_p
[ { "abbrev": true, "full_module": "Hacl.HPKE.Interface.AEAD", "short_module": "IAEAD" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.Hash", "short_module": "IHash" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.HKDF", "short_module": "IHK" }, { "abbrev": true, "full_module": "Hacl.HPKE.Interface.DH", "short_module": "IDH" }, { "abbrev": false, "full_module": "Hacl.Meta.HPKE", "short_module": null }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "AEAD" }, { "abbrev": true, "full_module": "Spec.Agile.DH", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let setupBaseR = hpke_setupBaseR_higher #cs vale_p IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64
val setupBaseR: setupBaseR_st cs vale_p let setupBaseR =
false
null
false
hpke_setupBaseR_higher #cs vale_p IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64
{ "checked_file": "Hacl.HPKE.Curve64_CP256_SHA256.fst.checked", "dependencies": [ "prims.fst.checked", "Hacl.Meta.HPKE.fst.checked", "Hacl.Meta.HPKE.fst.checked", "Hacl.HPKE.Interface.HKDF.fst.checked", "Hacl.HPKE.Interface.Hash.fst.checked", "Hacl.HPKE.Interface.DH.fst.checked", "Hacl.HPKE.Interface.AEAD.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Hacl.HPKE.Curve64_CP256_SHA256.fst" }
[ "total" ]
[ "Hacl.Meta.HPKE.hpke_setupBaseR_higher", "Hacl.HPKE.Curve64_CP256_SHA256.cs", "Hacl.HPKE.Curve64_CP256_SHA256.vale_p", "Hacl.HPKE.Interface.HKDF.hkdf_expand256", "Hacl.HPKE.Interface.HKDF.hkdf_extract256", "Hacl.HPKE.Interface.DH.dh_c64", "Hacl.HPKE.Interface.DH.secret_to_public_c64" ]
[]
module Hacl.HPKE.Curve64_CP256_SHA256 open Hacl.Meta.HPKE module IDH = Hacl.HPKE.Interface.DH module IHK = Hacl.HPKE.Interface.HKDF module IHash = Hacl.HPKE.Interface.Hash module IAEAD = Hacl.HPKE.Interface.AEAD friend Hacl.Meta.HPKE #set-options "--fuel 0 --ifuel 0" let setupBaseS = hpke_setupBaseS_higher #cs vale_p IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256
false
true
Hacl.HPKE.Curve64_CP256_SHA256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val setupBaseR: setupBaseR_st cs vale_p
[]
Hacl.HPKE.Curve64_CP256_SHA256.setupBaseR
{ "file_name": "code/hpke/Hacl.HPKE.Curve64_CP256_SHA256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.HPKE.setupBaseR_st Hacl.HPKE.Curve64_CP256_SHA256.cs Hacl.HPKE.Curve64_CP256_SHA256.vale_p
{ "end_col": 164, "end_line": 16, "start_col": 17, "start_line": 16 }
Prims.Tot
val parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32
val parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) =
false
null
false
parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.VLData.parse32_vldata_gen", "LowParse.Spec.VLData.unconstrained_bounded_integer", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.bool", "Prims.eq2", "LowParse.Spec.VLData.parse_vldata_gen_kind", "LowParse.Spec.VLData.parse_vldata" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p))
[]
LowParse.SLow.VLData.parse32_vldata
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> p32: LowParse.SLow.Base.parser32 p -> LowParse.SLow.Base.parser32 (LowParse.Spec.VLData.parse_vldata sz p)
{ "end_col": 78, "end_line": 50, "start_col": 2, "start_line": 50 }
Prims.Tot
val parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz {f i == true}) : Tot (parser32 (parse_vldata_payload sz f p i))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input
val parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz {f i == true}) : Tot (parser32 (parse_vldata_payload sz f p i)) let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz {f i == true}) : Tot (parser32 (parse_vldata_payload sz f p i)) =
false
null
false
fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.bool", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "Prims.eq2", "LowParse.SLow.Base.bytes32", "LowParse.SLow.FLData.parse32_fldata", "FStar.UInt32.v", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.VLData.parse_vldata_payload_kind", "LowParse.Spec.VLData.parse_vldata_payload" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } )
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz {f i == true}) : Tot (parser32 (parse_vldata_payload sz f p i))
[]
LowParse.SLow.VLData.parse32_vldata_payload
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> f: (_: LowParse.Spec.BoundedInt.bounded_integer sz -> Prims.GTot Prims.bool) -> p32: LowParse.SLow.Base.parser32 p -> i: LowParse.Spec.BoundedInt.bounded_integer sz {f i == true} -> LowParse.SLow.Base.parser32 (LowParse.Spec.VLData.parse_vldata_payload sz f p i)
{ "end_col": 62, "end_line": 22, "start_col": 2, "start_line": 22 }
Prims.Tot
val parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f': (x: bounded_integer sz -> Tot (y: bool{y == f x}))) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32)
val parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f': (x: bounded_integer sz -> Tot (y: bool{y == f x}))) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f': (x: bounded_integer sz -> Tot (y: bool{y == f x}))) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) =
false
null
false
[@@ inline_let ]let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32)
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.bool", "Prims.eq2", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.Combinators.parse32_and_then", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.SLow.Combinators.parse32_filter", "LowParse.SLow.BoundedInt.parse32_bounded_integer", "LowParse.Spec.VLData.parse_vldata_payload_kind", "LowParse.Spec.VLData.parse_vldata_payload", "LowParse.SLow.VLData.parse32_vldata_payload", "Prims.unit", "LowParse.Spec.VLData.parse_vldata_gen_eq_def", "LowParse.Spec.VLData.parse_vldata_gen_kind", "LowParse.Spec.VLData.parse_vldata_gen" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f': (x: bounded_integer sz -> Tot (y: bool{y == f x}))) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p))
[]
LowParse.SLow.VLData.parse32_vldata_gen
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> f: (_: LowParse.Spec.BoundedInt.bounded_integer sz -> Prims.GTot Prims.bool) -> f': (x: LowParse.Spec.BoundedInt.bounded_integer sz -> y: Prims.bool{y == f x}) -> p32: LowParse.SLow.Base.parser32 p -> LowParse.SLow.Base.parser32 (LowParse.Spec.VLData.parse_vldata_gen sz f p)
{ "end_col": 37, "end_line": 40, "start_col": 2, "start_line": 34 }
Prims.Tot
val check_vldata_payload_size32 (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967295}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (input: t) : Tot (y: bool{y == true <==> parse_bounded_vldata_strong_pred min max s input})
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let check_vldata_payload_size32 (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967295 } ) // necessary to exclude the overflow case; enough to be compatible with serialize32 (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (input: t) : Tot (y: bool { y == true <==> parse_bounded_vldata_strong_pred min max s input } ) = let sz : U32.t = s32 input in [@inline_let] let y : bool = not (sz = u32_max || U32.lt sz min32 || U32.lt max32 sz) in [@inline_let] let _ : squash (y == true <==> parse_bounded_vldata_strong_pred min max s input) = if sz = u32_max then if Seq.length (serialize s input) > U32.v u32_max then () else begin assert (U32.v u32_max == Seq.length (serialize s input)); assert_norm (U32.v u32_max == 4294967295); assert (Seq.length (serialize s input) > max); assert (~ (parse_bounded_vldata_strong_pred min max s input)) end else if Seq.length (serialize s input) > U32.v u32_max then () else () in y
val check_vldata_payload_size32 (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967295}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (input: t) : Tot (y: bool{y == true <==> parse_bounded_vldata_strong_pred min max s input}) let check_vldata_payload_size32 (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967295}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (input: t) : Tot (y: bool{y == true <==> parse_bounded_vldata_strong_pred min max s input}) =
false
null
false
let sz:U32.t = s32 input in [@@ inline_let ]let y:bool = not (sz = u32_max || U32.lt sz min32 || U32.lt max32 sz) in [@@ inline_let ]let _:squash (y == true <==> parse_bounded_vldata_strong_pred min max s input) = if sz = u32_max then if Seq.length (serialize s input) > U32.v u32_max then () else (assert (U32.v u32_max == Seq.length (serialize s input)); assert_norm (U32.v u32_max == 4294967295); assert (Seq.length (serialize s input) > max); assert (~(parse_bounded_vldata_strong_pred min max s input))) else if Seq.length (serialize s input) > U32.v u32_max then () in y
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "Prims.squash", "Prims.l_iff", "Prims.bool", "LowParse.Spec.VLData.parse_bounded_vldata_strong_pred", "Prims.op_Equality", "LowParse.SLow.Base.u32_max", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.Base.serialize", "Prims._assert", "Prims.l_not", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_Negation", "Prims.op_BarBar", "FStar.UInt32.lt" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32 inline_for_extraction let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) = [@inline_let] let sz : integer_size = l in [@inline_let] let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in res) let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) = let sz : integer_size = l in let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in let pl = s32 input in assert (B32.reveal pl == s input); let len = B32.len pl in let nlen = U32.v len in assert (min <= nlen /\ nlen <= max); let slen = ser (len <: bounded_integer sz) in assert (B32.reveal slen == serialize (serialize_bounded_integer sz) len); seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in assert (B32.reveal res == Seq.append (B32.reveal slen) (B32.reveal pl)); assert (B32.reveal res == serialize_bounded_vldata_strong_aux min max l s input); assert (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res) inline_for_extraction let serialize32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s)) = fun (input: parse_bounded_vldata_strong_t min max s) -> serialize32_bounded_vldata_strong_correct min max l s32 input; (serialize32_bounded_vldata_strong_aux min max l s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res } )) inline_for_extraction let serialize32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s)) = serialize32_bounded_vldata_strong' min max (log256' max) s32 inline_for_extraction let serialize32_bounded_vldata (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s { serialize_bounded_vldata_precond min max k } ) : Tot (serializer32 (serialize_bounded_vldata min max s)) = fun (input: t) -> [@inline_let] let _ : unit = let Some (_, consumed) = parse p (serialize s input) in () in serialize32_bounded_vldata_strong_correct min max (log256' max) s32 input; (serialize32_bounded_vldata_strong_aux min max (log256' max) s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata min max s) input res } )) #reset-options "--z3rlimit 32 --z3cliopt smt.arith.nl=false" inline_for_extraction let check_vldata_payload_size32 (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967295 } ) // necessary to exclude the overflow case; enough to be compatible with serialize32 (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (input: t)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val check_vldata_payload_size32 (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967295}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (input: t) : Tot (y: bool{y == true <==> parse_bounded_vldata_strong_pred min max s input})
[]
LowParse.SLow.VLData.check_vldata_payload_size32
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967295} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> s32: LowParse.SLow.Base.size32 s -> input: t -> y: Prims.bool{y == true <==> LowParse.Spec.VLData.parse_bounded_vldata_strong_pred min max s input}
{ "end_col": 3, "end_line": 319, "start_col": 1, "start_line": 297 }
Prims.Tot
val parse32_bounded_vldata (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32
val parse32_bounded_vldata (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) let parse32_bounded_vldata (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) =
false
null
false
parse32_bounded_vldata' min min32 max max32 (log256' max) p32
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.VLData.parse32_bounded_vldata'", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_vldata (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p))
[]
LowParse.SLow.VLData.parse32_bounded_vldata
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> p32: LowParse.SLow.Base.parser32 p -> LowParse.SLow.Base.parser32 (LowParse.Spec.VLData.parse_bounded_vldata min max p)
{ "end_col": 63, "end_line": 83, "start_col": 2, "start_line": 83 }
Prims.Tot
val serialize32_bounded_vldata_strong (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s)) = serialize32_bounded_vldata_strong' min max (log256' max) s32
val serialize32_bounded_vldata_strong (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s)) let serialize32_bounded_vldata_strong (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s)) =
false
null
false
serialize32_bounded_vldata_strong' min max (log256' max) s32
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.partial_serializer32", "LowParse.SLow.VLData.serialize32_bounded_vldata_strong'", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Base.serializer32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.VLData.parse_bounded_vldata_strong", "LowParse.Spec.VLData.serialize_bounded_vldata_strong" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32 inline_for_extraction let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) = [@inline_let] let sz : integer_size = l in [@inline_let] let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in res) let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) = let sz : integer_size = l in let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in let pl = s32 input in assert (B32.reveal pl == s input); let len = B32.len pl in let nlen = U32.v len in assert (min <= nlen /\ nlen <= max); let slen = ser (len <: bounded_integer sz) in assert (B32.reveal slen == serialize (serialize_bounded_integer sz) len); seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in assert (B32.reveal res == Seq.append (B32.reveal slen) (B32.reveal pl)); assert (B32.reveal res == serialize_bounded_vldata_strong_aux min max l s input); assert (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res) inline_for_extraction let serialize32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s)) = fun (input: parse_bounded_vldata_strong_t min max s) -> serialize32_bounded_vldata_strong_correct min max l s32 input; (serialize32_bounded_vldata_strong_aux min max l s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res } )) inline_for_extraction let serialize32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_vldata_strong (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s))
[]
LowParse.SLow.VLData.serialize32_bounded_vldata_strong
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> s32: LowParse.SLow.Base.partial_serializer32 s -> LowParse.SLow.Base.serializer32 (LowParse.Spec.VLData.serialize_bounded_vldata_strong min max s )
{ "end_col": 62, "end_line": 261, "start_col": 2, "start_line": 261 }
Prims.Tot
val parse32_bounded_vldata_strong (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32
val parse32_bounded_vldata_strong (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) let parse32_bounded_vldata_strong (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) =
false
null
false
parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.parser32", "LowParse.SLow.VLData.parse32_bounded_vldata_strong'", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.VLData.parse_bounded_vldata_strong" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_vldata_strong (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s))
[]
LowParse.SLow.VLData.parse32_bounded_vldata_strong
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> s: LowParse.Spec.Base.serializer p -> p32: LowParse.SLow.Base.parser32 p -> LowParse.SLow.Base.parser32 (LowParse.Spec.VLData.parse_bounded_vldata_strong min max s)
{ "end_col": 72, "end_line": 181, "start_col": 2, "start_line": 181 }
Prims.Tot
val parse32_bounded_vldata_strong' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input )
val parse32_bounded_vldata_strong' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) =
false
null
false
make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input)
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.make_parser32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.VLData.parse_bounded_vldata_strong'", "LowParse.SLow.Base.bytes32", "LowParse.SLow.VLData.parse32_bounded_vldata_strong_aux", "Prims.unit", "LowParse.SLow.VLData.parse32_bounded_vldata_strong_correct", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_vldata_strong' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s))
[]
LowParse.SLow.VLData.parse32_bounded_vldata_strong'
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> s: LowParse.Spec.Base.serializer p -> p32: LowParse.SLow.Base.parser32 p -> LowParse.SLow.Base.parser32 (LowParse.Spec.VLData.parse_bounded_vldata_strong' min max l s)
{ "end_col": 5, "end_line": 167, "start_col": 2, "start_line": 162 }
Prims.Tot
val parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed)
val parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) =
false
null
false
let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1:t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed)
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.VLData.parse_bounded_vldata_strong_pred", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Combinators.parse_strengthen", "LowParse.Spec.VLData.parse_bounded_vldata'", "LowParse.Spec.VLData.parse_bounded_vldata_strong_correct", "LowParse.SLow.Combinators.parse32_strengthen", "LowParse.SLow.VLData.parse32_bounded_vldata'" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t))
[]
LowParse.SLow.VLData.parse32_bounded_vldata_strong_aux
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> s: LowParse.Spec.Base.serializer p -> p32: LowParse.SLow.Base.parser32 p -> input: LowParse.SLow.Base.bytes32 -> FStar.Pervasives.Native.option (LowParse.Spec.VLData.parse_bounded_vldata_strong_t min max s * FStar.UInt32.t)
{ "end_col": 77, "end_line": 113, "start_col": 1, "start_line": 99 }
Prims.Tot
val parse32_bounded_vldata' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input)
val parse32_bounded_vldata' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) let parse32_bounded_vldata' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) =
false
null
false
[@@ inline_let ]let _ = parse_bounded_vldata_correct min max l p in [@@ inline_let ]let sz:integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input)
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "LowParse.SLow.VLData.parse32_vldata_gen", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.op_Negation", "Prims.op_BarBar", "FStar.UInt32.lt", "Prims.bool", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata'", "LowParse.Spec.BoundedInt.integer_size", "Prims.unit", "LowParse.Spec.VLData.parse_bounded_vldata_correct" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_vldata' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p))
[]
LowParse.SLow.VLData.parse32_bounded_vldata'
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> p32: LowParse.SLow.Base.parser32 p -> LowParse.SLow.Base.parser32 (LowParse.Spec.VLData.parse_bounded_vldata' min max l p)
{ "end_col": 118, "end_line": 70, "start_col": 2, "start_line": 66 }
Prims.Tot
val serialize32_bounded_vldata_strong' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s)) = fun (input: parse_bounded_vldata_strong_t min max s) -> serialize32_bounded_vldata_strong_correct min max l s32 input; (serialize32_bounded_vldata_strong_aux min max l s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res } ))
val serialize32_bounded_vldata_strong' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s)) let serialize32_bounded_vldata_strong' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s)) =
false
null
false
fun (input: parse_bounded_vldata_strong_t min max s) -> serialize32_bounded_vldata_strong_correct min max l s32 input; (serialize32_bounded_vldata_strong_aux min max l s32 input <: (res: bytes32{serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res}))
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.partial_serializer32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.SLow.VLData.serialize32_bounded_vldata_strong_aux", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong'", "LowParse.Spec.VLData.serialize_bounded_vldata_strong'", "Prims.unit", "LowParse.SLow.VLData.serialize32_bounded_vldata_strong_correct", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32 inline_for_extraction let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) = [@inline_let] let sz : integer_size = l in [@inline_let] let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in res) let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) = let sz : integer_size = l in let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in let pl = s32 input in assert (B32.reveal pl == s input); let len = B32.len pl in let nlen = U32.v len in assert (min <= nlen /\ nlen <= max); let slen = ser (len <: bounded_integer sz) in assert (B32.reveal slen == serialize (serialize_bounded_integer sz) len); seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in assert (B32.reveal res == Seq.append (B32.reveal slen) (B32.reveal pl)); assert (B32.reveal res == serialize_bounded_vldata_strong_aux min max l s input); assert (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res) inline_for_extraction let serialize32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_vldata_strong' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s))
[]
LowParse.SLow.VLData.serialize32_bounded_vldata_strong'
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> s32: LowParse.SLow.Base.partial_serializer32 s -> LowParse.SLow.Base.serializer32 (LowParse.Spec.VLData.serialize_bounded_vldata_strong' min max l s)
{ "end_col": 162, "end_line": 249, "start_col": 2, "start_line": 247 }
Prims.Tot
val serialize32_bounded_vldata (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s {serialize_bounded_vldata_precond min max k}) : Tot (serializer32 (serialize_bounded_vldata min max s))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_vldata (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s { serialize_bounded_vldata_precond min max k } ) : Tot (serializer32 (serialize_bounded_vldata min max s)) = fun (input: t) -> [@inline_let] let _ : unit = let Some (_, consumed) = parse p (serialize s input) in () in serialize32_bounded_vldata_strong_correct min max (log256' max) s32 input; (serialize32_bounded_vldata_strong_aux min max (log256' max) s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata min max s) input res } ))
val serialize32_bounded_vldata (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s {serialize_bounded_vldata_precond min max k}) : Tot (serializer32 (serialize_bounded_vldata min max s)) let serialize32_bounded_vldata (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s {serialize_bounded_vldata_precond min max k}) : Tot (serializer32 (serialize_bounded_vldata min max s)) =
false
null
false
fun (input: t) -> [@@ inline_let ]let _:unit = let Some (_, consumed) = parse p (serialize s input) in () in serialize32_bounded_vldata_strong_correct min max (log256' max) s32 input; (serialize32_bounded_vldata_strong_aux min max (log256' max) s32 input <: (res: bytes32{serializer32_correct (serialize_bounded_vldata min max s) input res}))
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.partial_serializer32", "LowParse.Spec.VLData.serialize_bounded_vldata_precond", "LowParse.SLow.VLData.serialize32_bounded_vldata_strong_aux", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata", "LowParse.Spec.VLData.serialize_bounded_vldata", "Prims.unit", "LowParse.SLow.VLData.serialize32_bounded_vldata_strong_correct", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.serialize", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.parse", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32 inline_for_extraction let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) = [@inline_let] let sz : integer_size = l in [@inline_let] let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in res) let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) = let sz : integer_size = l in let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in let pl = s32 input in assert (B32.reveal pl == s input); let len = B32.len pl in let nlen = U32.v len in assert (min <= nlen /\ nlen <= max); let slen = ser (len <: bounded_integer sz) in assert (B32.reveal slen == serialize (serialize_bounded_integer sz) len); seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in assert (B32.reveal res == Seq.append (B32.reveal slen) (B32.reveal pl)); assert (B32.reveal res == serialize_bounded_vldata_strong_aux min max l s input); assert (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res) inline_for_extraction let serialize32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s)) = fun (input: parse_bounded_vldata_strong_t min max s) -> serialize32_bounded_vldata_strong_correct min max l s32 input; (serialize32_bounded_vldata_strong_aux min max l s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res } )) inline_for_extraction let serialize32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s)) = serialize32_bounded_vldata_strong' min max (log256' max) s32 inline_for_extraction let serialize32_bounded_vldata (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s { serialize_bounded_vldata_precond min max k } )
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_vldata (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s {serialize_bounded_vldata_precond min max k}) : Tot (serializer32 (serialize_bounded_vldata min max s))
[]
LowParse.SLow.VLData.serialize32_bounded_vldata
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> s32: LowParse.SLow.Base.partial_serializer32 s {LowParse.Spec.VLData.serialize_bounded_vldata_precond min max k} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.VLData.serialize_bounded_vldata min max s)
{ "end_col": 164, "end_line": 280, "start_col": 2, "start_line": 273 }
Prims.Tot
val size32_bounded_vldata_strong (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t{U32.v sz32 == log256' max}) : Tot (size32 (serialize_bounded_vldata_strong min max s))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4, otherwise add overflows (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t { U32.v sz32 == log256' max } ) : Tot (size32 (serialize_bounded_vldata_strong min max s)) = size32_bounded_vldata_strong' min max (log256' max) s32 sz32
val size32_bounded_vldata_strong (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t{U32.v sz32 == log256' max}) : Tot (size32 (serialize_bounded_vldata_strong min max s)) let size32_bounded_vldata_strong (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t{U32.v sz32 == log256' max}) : Tot (size32 (serialize_bounded_vldata_strong min max s)) =
false
null
false
size32_bounded_vldata_strong' min max (log256' max) s32 sz32
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.VLData.size32_bounded_vldata_strong'", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.VLData.parse_bounded_vldata_strong", "LowParse.Spec.VLData.serialize_bounded_vldata_strong" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32 inline_for_extraction let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) = [@inline_let] let sz : integer_size = l in [@inline_let] let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in res) let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) = let sz : integer_size = l in let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in let pl = s32 input in assert (B32.reveal pl == s input); let len = B32.len pl in let nlen = U32.v len in assert (min <= nlen /\ nlen <= max); let slen = ser (len <: bounded_integer sz) in assert (B32.reveal slen == serialize (serialize_bounded_integer sz) len); seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in assert (B32.reveal res == Seq.append (B32.reveal slen) (B32.reveal pl)); assert (B32.reveal res == serialize_bounded_vldata_strong_aux min max l s input); assert (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res) inline_for_extraction let serialize32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s)) = fun (input: parse_bounded_vldata_strong_t min max s) -> serialize32_bounded_vldata_strong_correct min max l s32 input; (serialize32_bounded_vldata_strong_aux min max l s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res } )) inline_for_extraction let serialize32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s)) = serialize32_bounded_vldata_strong' min max (log256' max) s32 inline_for_extraction let serialize32_bounded_vldata (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s { serialize_bounded_vldata_precond min max k } ) : Tot (serializer32 (serialize_bounded_vldata min max s)) = fun (input: t) -> [@inline_let] let _ : unit = let Some (_, consumed) = parse p (serialize s input) in () in serialize32_bounded_vldata_strong_correct min max (log256' max) s32 input; (serialize32_bounded_vldata_strong_aux min max (log256' max) s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata min max s) input res } )) #reset-options "--z3rlimit 32 --z3cliopt smt.arith.nl=false" inline_for_extraction let check_vldata_payload_size32 (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967295 } ) // necessary to exclude the overflow case; enough to be compatible with serialize32 (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (input: t) : Tot (y: bool { y == true <==> parse_bounded_vldata_strong_pred min max s input } ) = let sz : U32.t = s32 input in [@inline_let] let y : bool = not (sz = u32_max || U32.lt sz min32 || U32.lt max32 sz) in [@inline_let] let _ : squash (y == true <==> parse_bounded_vldata_strong_pred min max s input) = if sz = u32_max then if Seq.length (serialize s input) > U32.v u32_max then () else begin assert (U32.v u32_max == Seq.length (serialize s input)); assert_norm (U32.v u32_max == 4294967295); assert (Seq.length (serialize s input) > max); assert (~ (parse_bounded_vldata_strong_pred min max s input)) end else if Seq.length (serialize s input) > U32.v u32_max then () else () in y inline_for_extraction let size32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4, otherwise add overflows (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t { U32.v sz32 == l } ) : Tot (size32 (serialize_bounded_vldata_strong' min max l s)) = (fun (input: parse_bounded_vldata_strong_t min max s) -> let len = s32 input in [@inline_let] let _ = assert_norm (U32.v u32_max == 4294967295) in [@inline_let] let _ = assert (min <= U32.v len /\ U32.v len <= max) in [@inline_let] let res : U32.t = U32.add sz32 len in (res <: (res: U32.t { size32_postcond (serialize_bounded_vldata_strong' min max l s) input res } ))) inline_for_extraction let size32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4, otherwise add overflows (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t { U32.v sz32 == log256' max } )
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_bounded_vldata_strong (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t{U32.v sz32 == log256' max}) : Tot (size32 (serialize_bounded_vldata_strong min max s))
[]
LowParse.SLow.VLData.size32_bounded_vldata_strong
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> s32: LowParse.SLow.Base.size32 s -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == LowParse.Spec.BoundedInt.log256' max} -> LowParse.SLow.Base.size32 (LowParse.Spec.VLData.serialize_bounded_vldata_strong min max s)
{ "end_col": 62, "end_line": 354, "start_col": 2, "start_line": 354 }
Prims.Tot
val serialize32_bounded_vldata_strong_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32)
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) = [@inline_let] let sz : integer_size = l in [@inline_let] let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in res)
val serialize32_bounded_vldata_strong_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) =
false
null
false
[@@ inline_let ]let sz:integer_size = l in [@@ inline_let ]let ser:serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res:bytes32 = B32.b32append slen pl in res)
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.partial_serializer32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.SLow.Base.bytes32", "LowParse.Bytes32.b32append", "Prims.unit", "LowParse.Spec.Combinators.seq_slice_append_r", "FStar.Bytes.byte", "FStar.Bytes.reveal", "LowParse.Spec.Combinators.seq_slice_append_l", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "Prims._assert", "FStar.UInt32.v", "FStar.UInt32.t", "FStar.Bytes.len", "LowParse.SLow.Base.serializer32", "LowParse.SLow.BoundedInt.serialize32_bounded_integer", "LowParse.Spec.BoundedInt.integer_size" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32 inline_for_extraction let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s)
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_vldata_strong_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32)
[]
LowParse.SLow.VLData.serialize32_bounded_vldata_strong_aux
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> s32: LowParse.SLow.Base.partial_serializer32 s -> _: LowParse.Spec.VLData.parse_bounded_vldata_strong_t min max s -> LowParse.SLow.Base.bytes32
{ "end_col": 8, "end_line": 206, "start_col": 2, "start_line": 194 }
FStar.Pervasives.Lemma
val parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma (let res:option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res)
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res)
val parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma (let res:option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma (let res:option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) =
false
null
true
let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1:t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res)
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "lemma" ]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_pred", "Prims._assert", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.VLData.parse_bounded_vldata_strong'", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "LowParse.Spec.Combinators.parse_strengthen", "LowParse.Spec.VLData.parse_bounded_vldata'", "LowParse.Spec.VLData.parse_bounded_vldata_strong_correct", "LowParse.SLow.Combinators.parse32_strengthen", "LowParse.SLow.VLData.parse32_bounded_vldata'", "Prims.l_True", "Prims.squash", "LowParse.SLow.VLData.parse32_bounded_vldata_strong_aux", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma (let res:option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res)
[]
LowParse.SLow.VLData.parse32_bounded_vldata_strong_correct
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> s: LowParse.Spec.Base.serializer p -> p32: LowParse.SLow.Base.parser32 p -> input: LowParse.SLow.Base.bytes32 -> FStar.Pervasives.Lemma (ensures (let res = LowParse.SLow.VLData.parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in LowParse.SLow.Base.parser32_correct (LowParse.Spec.VLData.parse_bounded_vldata_strong' min max l s) input res))
{ "end_col": 82, "end_line": 147, "start_col": 1, "start_line": 132 }
Prims.Tot
val size32_bounded_vldata (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s {serialize_bounded_vldata_precond min max k}) (sz32: U32.t{U32.v sz32 == log256' max}) : Tot (size32 (serialize_bounded_vldata min max s))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_bounded_vldata (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s { serialize_bounded_vldata_precond min max k } ) (sz32: U32.t { U32.v sz32 == log256' max } ) : Tot (size32 (serialize_bounded_vldata min max s)) = fun (input: t) -> [@inline_let] let _ : unit = let Some (_, consumed) = parse p (serialize s input) in () in (size32_bounded_vldata_strong min max s32 sz32 input <: (res: U32.t { size32_postcond (serialize_bounded_vldata min max s) input res } ))
val size32_bounded_vldata (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s {serialize_bounded_vldata_precond min max k}) (sz32: U32.t{U32.v sz32 == log256' max}) : Tot (size32 (serialize_bounded_vldata min max s)) let size32_bounded_vldata (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s {serialize_bounded_vldata_precond min max k}) (sz32: U32.t{U32.v sz32 == log256' max}) : Tot (size32 (serialize_bounded_vldata min max s)) =
false
null
false
fun (input: t) -> [@@ inline_let ]let _:unit = let Some (_, consumed) = parse p (serialize s input) in () in (size32_bounded_vldata_strong min max s32 sz32 input <: (res: U32.t{size32_postcond (serialize_bounded_vldata min max s) input res}))
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "LowParse.Spec.VLData.serialize_bounded_vldata_precond", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.VLData.size32_bounded_vldata_strong", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata", "LowParse.Spec.VLData.serialize_bounded_vldata", "Prims.unit", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.serialize", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.parse" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32 inline_for_extraction let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) = [@inline_let] let sz : integer_size = l in [@inline_let] let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in res) let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) = let sz : integer_size = l in let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in let pl = s32 input in assert (B32.reveal pl == s input); let len = B32.len pl in let nlen = U32.v len in assert (min <= nlen /\ nlen <= max); let slen = ser (len <: bounded_integer sz) in assert (B32.reveal slen == serialize (serialize_bounded_integer sz) len); seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in assert (B32.reveal res == Seq.append (B32.reveal slen) (B32.reveal pl)); assert (B32.reveal res == serialize_bounded_vldata_strong_aux min max l s input); assert (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res) inline_for_extraction let serialize32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s)) = fun (input: parse_bounded_vldata_strong_t min max s) -> serialize32_bounded_vldata_strong_correct min max l s32 input; (serialize32_bounded_vldata_strong_aux min max l s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res } )) inline_for_extraction let serialize32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s)) = serialize32_bounded_vldata_strong' min max (log256' max) s32 inline_for_extraction let serialize32_bounded_vldata (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s { serialize_bounded_vldata_precond min max k } ) : Tot (serializer32 (serialize_bounded_vldata min max s)) = fun (input: t) -> [@inline_let] let _ : unit = let Some (_, consumed) = parse p (serialize s input) in () in serialize32_bounded_vldata_strong_correct min max (log256' max) s32 input; (serialize32_bounded_vldata_strong_aux min max (log256' max) s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata min max s) input res } )) #reset-options "--z3rlimit 32 --z3cliopt smt.arith.nl=false" inline_for_extraction let check_vldata_payload_size32 (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967295 } ) // necessary to exclude the overflow case; enough to be compatible with serialize32 (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (input: t) : Tot (y: bool { y == true <==> parse_bounded_vldata_strong_pred min max s input } ) = let sz : U32.t = s32 input in [@inline_let] let y : bool = not (sz = u32_max || U32.lt sz min32 || U32.lt max32 sz) in [@inline_let] let _ : squash (y == true <==> parse_bounded_vldata_strong_pred min max s input) = if sz = u32_max then if Seq.length (serialize s input) > U32.v u32_max then () else begin assert (U32.v u32_max == Seq.length (serialize s input)); assert_norm (U32.v u32_max == 4294967295); assert (Seq.length (serialize s input) > max); assert (~ (parse_bounded_vldata_strong_pred min max s input)) end else if Seq.length (serialize s input) > U32.v u32_max then () else () in y inline_for_extraction let size32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4, otherwise add overflows (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t { U32.v sz32 == l } ) : Tot (size32 (serialize_bounded_vldata_strong' min max l s)) = (fun (input: parse_bounded_vldata_strong_t min max s) -> let len = s32 input in [@inline_let] let _ = assert_norm (U32.v u32_max == 4294967295) in [@inline_let] let _ = assert (min <= U32.v len /\ U32.v len <= max) in [@inline_let] let res : U32.t = U32.add sz32 len in (res <: (res: U32.t { size32_postcond (serialize_bounded_vldata_strong' min max l s) input res } ))) inline_for_extraction let size32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4, otherwise add overflows (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t { U32.v sz32 == log256' max } ) : Tot (size32 (serialize_bounded_vldata_strong min max s)) = size32_bounded_vldata_strong' min max (log256' max) s32 sz32 inline_for_extraction let size32_bounded_vldata (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s { serialize_bounded_vldata_precond min max k } ) (sz32: U32.t { U32.v sz32 == log256' max } )
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_bounded_vldata (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s {serialize_bounded_vldata_precond min max k}) (sz32: U32.t{U32.v sz32 == log256' max}) : Tot (size32 (serialize_bounded_vldata min max s))
[]
LowParse.SLow.VLData.size32_bounded_vldata
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> s32: LowParse.SLow.Base.size32 s {LowParse.Spec.VLData.serialize_bounded_vldata_precond min max k} -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == LowParse.Spec.BoundedInt.log256' max} -> LowParse.SLow.Base.size32 (LowParse.Spec.VLData.serialize_bounded_vldata min max s)
{ "end_col": 139, "end_line": 373, "start_col": 2, "start_line": 367 }
FStar.Pervasives.Lemma
val serialize32_bounded_vldata_strong_correct (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) = let sz : integer_size = l in let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in let pl = s32 input in assert (B32.reveal pl == s input); let len = B32.len pl in let nlen = U32.v len in assert (min <= nlen /\ nlen <= max); let slen = ser (len <: bounded_integer sz) in assert (B32.reveal slen == serialize (serialize_bounded_integer sz) len); seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in assert (B32.reveal res == Seq.append (B32.reveal slen) (B32.reveal pl)); assert (B32.reveal res == serialize_bounded_vldata_strong_aux min max l s input); assert (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res)
val serialize32_bounded_vldata_strong_correct (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) =
false
null
true
let sz:integer_size = l in let ser:serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in let pl = s32 input in assert (B32.reveal pl == s input); let len = B32.len pl in let nlen = U32.v len in assert (min <= nlen /\ nlen <= max); let slen = ser (len <: bounded_integer sz) in assert (B32.reveal slen == serialize (serialize_bounded_integer sz) len); seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res:bytes32 = B32.b32append slen pl in assert (B32.reveal res == Seq.append (B32.reveal slen) (B32.reveal pl)); assert (B32.reveal res == serialize_bounded_vldata_strong_aux min max l s input); assert (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res)
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.partial_serializer32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "Prims._assert", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong'", "LowParse.Spec.VLData.serialize_bounded_vldata_strong'", "Prims.unit", "Prims.eq2", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "FStar.Bytes.reveal", "LowParse.Spec.VLData.serialize_bounded_vldata_strong_aux", "FStar.Bytes.byte", "FStar.Seq.Base.append", "LowParse.SLow.Base.bytes32", "LowParse.Bytes32.b32append", "LowParse.Spec.Combinators.seq_slice_append_r", "LowParse.Spec.Combinators.seq_slice_append_l", "LowParse.Spec.Base.serialize", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "FStar.UInt.uint_t", "FStar.UInt32.v", "FStar.UInt32.t", "FStar.Bytes.len", "LowParse.SLow.Base.serializer32", "LowParse.SLow.BoundedInt.serialize32_bounded_integer", "LowParse.Spec.BoundedInt.integer_size", "Prims.l_True", "Prims.squash", "LowParse.SLow.VLData.serialize32_bounded_vldata_strong_aux", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32 inline_for_extraction let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) = [@inline_let] let sz : integer_size = l in [@inline_let] let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in res) let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_vldata_strong_correct (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input))
[]
LowParse.SLow.VLData.serialize32_bounded_vldata_strong_correct
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> s32: LowParse.SLow.Base.partial_serializer32 s -> input: LowParse.Spec.VLData.parse_bounded_vldata_strong_t min max s -> FStar.Pervasives.Lemma (ensures LowParse.SLow.Base.serializer32_correct (LowParse.Spec.VLData.serialize_bounded_vldata_strong' min max l s) input (LowParse.SLow.VLData.serialize32_bounded_vldata_strong_aux min max l s32 input))
{ "end_col": 88, "end_line": 234, "start_col": 1, "start_line": 220 }
Prims.Tot
val size32_bounded_vldata_strong' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t{U32.v sz32 == l}) : Tot (size32 (serialize_bounded_vldata_strong' min max l s))
[ { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.FLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4, otherwise add overflows (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t { U32.v sz32 == l } ) : Tot (size32 (serialize_bounded_vldata_strong' min max l s)) = (fun (input: parse_bounded_vldata_strong_t min max s) -> let len = s32 input in [@inline_let] let _ = assert_norm (U32.v u32_max == 4294967295) in [@inline_let] let _ = assert (min <= U32.v len /\ U32.v len <= max) in [@inline_let] let res : U32.t = U32.add sz32 len in (res <: (res: U32.t { size32_postcond (serialize_bounded_vldata_strong' min max l s) input res } )))
val size32_bounded_vldata_strong' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t{U32.v sz32 == l}) : Tot (size32 (serialize_bounded_vldata_strong' min max l s)) let size32_bounded_vldata_strong' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t{U32.v sz32 == l}) : Tot (size32 (serialize_bounded_vldata_strong' min max l s)) =
false
null
false
(fun (input: parse_bounded_vldata_strong_t min max s) -> let len = s32 input in [@@ inline_let ]let _ = assert_norm (U32.v u32_max == 4294967295) in [@@ inline_let ]let _ = assert (min <= U32.v len /\ U32.v len <= max) in [@@ inline_let ]let res:U32.t = U32.add sz32 len in (res <: (res: U32.t{size32_postcond (serialize_bounded_vldata_strong' min max l s) input res})))
{ "checked_file": "LowParse.SLow.VLData.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLData.fsti.checked", "LowParse.SLow.FLData.fst.checked", "LowParse.SLow.BoundedInt.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.VLData.fst" }
[ "total" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "FStar.UInt32.v", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong'", "LowParse.Spec.VLData.serialize_bounded_vldata_strong'", "FStar.UInt32.add", "Prims.unit", "Prims._assert", "FStar.Pervasives.assert_norm", "LowParse.SLow.Base.u32_max" ]
[]
module LowParse.SLow.VLData include LowParse.Spec.VLData include LowParse.SLow.FLData include LowParse.SLow.BoundedInt // for bounded_integer module Seq = FStar.Seq module U32 = FStar.UInt32 module B32 = LowParse.Bytes32 (* Parsers and serializers for the payload *) inline_for_extraction let parse32_vldata_payload (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (i: bounded_integer sz { f i == true } ) : Tot (parser32 (parse_vldata_payload sz f p i)) = fun (input: bytes32) -> parse32_fldata p32 (U32.v i) i input inline_for_extraction let parse32_vldata_gen (sz: integer_size) (f: (bounded_integer sz -> GTot bool)) (f' : (x: bounded_integer sz) -> Tot (y: bool {y == f x})) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata_gen sz f p)) = [@inline_let] let _ = parse_vldata_gen_eq_def sz f p in parse32_and_then (parse32_filter (parse32_bounded_integer sz) f f') (parse_vldata_payload sz f p) () (parse32_vldata_payload sz f p32) inline_for_extraction let parse32_vldata (sz: integer_size) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_vldata sz p)) = parse32_vldata_gen sz (unconstrained_bounded_integer sz) (fun _ -> true) p32 #set-options "--z3rlimit 32" inline_for_extraction let parse32_bounded_vldata' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata' min max l p)) = [@inline_let] let _ = parse_bounded_vldata_correct min max l p in [@inline_let] let sz : integer_size = l in (fun input -> parse32_vldata_gen sz (in_bounds min max) (fun i -> not (U32.lt i min32 || U32.lt max32 i)) p32 input) inline_for_extraction let parse32_bounded_vldata (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) : Tot (parser32 (parse_bounded_vldata min max p)) = parse32_bounded_vldata' min min32 max max32 (log256' max) p32 inline_for_extraction let parse32_bounded_vldata_strong_aux (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Tot (option (parse_bounded_vldata_strong_t min max #k #t #p s * U32.t)) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> None | Some (x, consumed) -> let x1 : t = x in Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) let parse32_bounded_vldata_strong_correct (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (input: bytes32) : Lemma ( let res : option (parse_bounded_vldata_strong_t min max s * U32.t) = parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input in parser32_correct (parse_bounded_vldata_strong' min max l s) input res) = let res = parse32_strengthen #(parse_bounded_vldata_strong_kind min max l k) #t #(parse_bounded_vldata' min max l #k #t p) (parse32_bounded_vldata' min min32 max max32 l #k #t #p p32) (parse_bounded_vldata_strong_pred min max #k #t #p s) (parse_bounded_vldata_strong_correct min max l #k #t #p s) input in match res with | None -> () | Some (x, consumed) -> let x1 : t = x in let res = Some ((x1 <: parse_bounded_vldata_strong_t min max #k #t #p s), consumed) in assert (parser32_correct (parse_bounded_vldata_strong' min max l s) input res) inline_for_extraction let parse32_bounded_vldata_strong' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong' min max l s)) = make_parser32 (parse_bounded_vldata_strong' min max l s) (fun input -> parse32_bounded_vldata_strong_correct min min32 max max32 l s p32 input; parse32_bounded_vldata_strong_aux min min32 max max32 l s p32 input ) inline_for_extraction let parse32_bounded_vldata_strong (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) : Tot (parser32 #_ #(parse_bounded_vldata_strong_t min max s) (parse_bounded_vldata_strong min max s)) = parse32_bounded_vldata_strong' min min32 max max32 (log256' max) s p32 inline_for_extraction let serialize32_bounded_vldata_strong_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (parse_bounded_vldata_strong_t min max s -> Tot bytes32) = [@inline_let] let sz : integer_size = l in [@inline_let] let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in (fun (input: parse_bounded_vldata_strong_t min max s) -> let pl = s32 input in let len = B32.len pl in assert (min <= U32.v len /\ U32.v len <= max); let slen = ser (len <: bounded_integer sz) in seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in res) let serialize32_bounded_vldata_strong_correct (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) (input: parse_bounded_vldata_strong_t min max s) : Lemma (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input (serialize32_bounded_vldata_strong_aux min max l s32 input)) = let sz : integer_size = l in let ser : serializer32 (serialize_bounded_integer sz) = serialize32_bounded_integer sz in let pl = s32 input in assert (B32.reveal pl == s input); let len = B32.len pl in let nlen = U32.v len in assert (min <= nlen /\ nlen <= max); let slen = ser (len <: bounded_integer sz) in assert (B32.reveal slen == serialize (serialize_bounded_integer sz) len); seq_slice_append_l (B32.reveal slen) (B32.reveal pl); seq_slice_append_r (B32.reveal slen) (B32.reveal pl); let res : bytes32 = B32.b32append slen pl in assert (B32.reveal res == Seq.append (B32.reveal slen) (B32.reveal pl)); assert (B32.reveal res == serialize_bounded_vldata_strong_aux min max l s input); assert (serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res) inline_for_extraction let serialize32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong' min max l s)) = fun (input: parse_bounded_vldata_strong_t min max s) -> serialize32_bounded_vldata_strong_correct min max l s32 input; (serialize32_bounded_vldata_strong_aux min max l s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata_strong' min max l s) input res } )) inline_for_extraction let serialize32_bounded_vldata_strong (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s) : Tot (serializer32 (serialize_bounded_vldata_strong min max s)) = serialize32_bounded_vldata_strong' min max (log256' max) s32 inline_for_extraction let serialize32_bounded_vldata (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: partial_serializer32 s { serialize_bounded_vldata_precond min max k } ) : Tot (serializer32 (serialize_bounded_vldata min max s)) = fun (input: t) -> [@inline_let] let _ : unit = let Some (_, consumed) = parse p (serialize s input) in () in serialize32_bounded_vldata_strong_correct min max (log256' max) s32 input; (serialize32_bounded_vldata_strong_aux min max (log256' max) s32 input <: (res: bytes32 { serializer32_correct (serialize_bounded_vldata min max s) input res } )) #reset-options "--z3rlimit 32 --z3cliopt smt.arith.nl=false" inline_for_extraction let check_vldata_payload_size32 (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967295 } ) // necessary to exclude the overflow case; enough to be compatible with serialize32 (max32: U32.t { U32.v max32 == max } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (input: t) : Tot (y: bool { y == true <==> parse_bounded_vldata_strong_pred min max s input } ) = let sz : U32.t = s32 input in [@inline_let] let y : bool = not (sz = u32_max || U32.lt sz min32 || U32.lt max32 sz) in [@inline_let] let _ : squash (y == true <==> parse_bounded_vldata_strong_pred min max s input) = if sz = u32_max then if Seq.length (serialize s input) > U32.v u32_max then () else begin assert (U32.v u32_max == Seq.length (serialize s input)); assert_norm (U32.v u32_max == 4294967295); assert (Seq.length (serialize s input) > max); assert (~ (parse_bounded_vldata_strong_pred min max s input)) end else if Seq.length (serialize s input) > U32.v u32_max then () else () in y inline_for_extraction let size32_bounded_vldata_strong' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // NOTE here: max must be less than 2^32 - 4, otherwise add overflows (l: nat { l >= log256' max /\ l <= 4 } ) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t { U32.v sz32 == l } )
false
false
LowParse.SLow.VLData.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_bounded_vldata_strong' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (sz32: U32.t{U32.v sz32 == l}) : Tot (size32 (serialize_bounded_vldata_strong' min max l s))
[]
LowParse.SLow.VLData.size32_bounded_vldata_strong'
{ "file_name": "src/lowparse/LowParse.SLow.VLData.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> s32: LowParse.SLow.Base.size32 s -> sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == l} -> LowParse.SLow.Base.size32 (LowParse.Spec.VLData.serialize_bounded_vldata_strong' min max l s)
{ "end_col": 105, "end_line": 341, "start_col": 2, "start_line": 333 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let prime (a:algorithm) = match a with | DH_Curve25519 -> Spec.Curve25519.prime | DH_P256 -> Spec.P256.prime
let prime (a: algorithm) =
false
null
false
match a with | DH_Curve25519 -> Spec.Curve25519.prime | DH_P256 -> Spec.P256.prime
{ "checked_file": "Spec.Agile.DH.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.DH.fst" }
[ "total" ]
[ "Spec.Agile.DH.algorithm", "Spec.Curve25519.prime", "Spec.P256.PointOps.prime", "Prims.pos" ]
[]
module Spec.Agile.DH open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants type algorithm = | DH_Curve25519 | DH_P256 inline_for_extraction let size_key (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 32 inline_for_extraction let size_public (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 64 inline_for_extraction
false
true
Spec.Agile.DH.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val prime : a: Spec.Agile.DH.algorithm -> Prims.pos
[]
Spec.Agile.DH.prime
{ "file_name": "specs/Spec.Agile.DH.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.DH.algorithm -> Prims.pos
{ "end_col": 30, "end_line": 31, "start_col": 2, "start_line": 29 }
Prims.Tot
val secret_to_public: a:algorithm -> scalar a -> Tot (option (serialized_point a))
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let secret_to_public a kpriv = match a with | DH_Curve25519 -> Some (Spec.Curve25519.secret_to_public kpriv) | DH_P256 -> Spec.P256.secret_to_public kpriv
val secret_to_public: a:algorithm -> scalar a -> Tot (option (serialized_point a)) let secret_to_public a kpriv =
false
null
false
match a with | DH_Curve25519 -> Some (Spec.Curve25519.secret_to_public kpriv) | DH_P256 -> Spec.P256.secret_to_public kpriv
{ "checked_file": "Spec.Agile.DH.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.DH.fst" }
[ "total" ]
[ "Spec.Agile.DH.algorithm", "Spec.Agile.DH.scalar", "FStar.Pervasives.Native.Some", "Spec.Agile.DH.serialized_point", "Spec.Curve25519.secret_to_public", "Spec.P256.secret_to_public", "FStar.Pervasives.Native.option" ]
[]
module Spec.Agile.DH open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants type algorithm = | DH_Curve25519 | DH_P256 inline_for_extraction let size_key (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 32 inline_for_extraction let size_public (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 64 inline_for_extraction let prime (a:algorithm) = match a with | DH_Curve25519 -> Spec.Curve25519.prime | DH_P256 -> Spec.P256.prime /// Types type scalar (a:algorithm) = lbytes (size_key a) type serialized_point (a:algorithm) = lbytes (size_public a) /// Functions val clamp: alg:algorithm{alg = DH_Curve25519} -> scalar alg -> Tot (scalar alg) let clamp a k = match a with | DH.DH_Curve25519 -> Spec.Curve25519.decodeScalar k #set-options "--z3rlimit 50" val dh: a:algorithm -> s:scalar a -> p:serialized_point a -> Tot (option (serialized_point a)) let dh a s p = match a with | DH_Curve25519 -> let output = Spec.Curve25519.scalarmult s p in let is_valid = not (lbytes_eq (create (size_public a) (u8 0)) output) in if is_valid then Some output else None | DH_P256 -> Spec.P256.ecdh p s val secret_to_public: a:algorithm -> scalar a -> Tot (option (serialized_point a))
false
false
Spec.Agile.DH.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val secret_to_public: a:algorithm -> scalar a -> Tot (option (serialized_point a))
[]
Spec.Agile.DH.secret_to_public
{ "file_name": "specs/Spec.Agile.DH.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.DH.algorithm -> kpriv: Spec.Agile.DH.scalar a -> FStar.Pervasives.Native.option (Spec.Agile.DH.serialized_point a)
{ "end_col": 47, "end_line": 62, "start_col": 2, "start_line": 60 }
Prims.Tot
val clamp: alg:algorithm{alg = DH_Curve25519} -> scalar alg -> Tot (scalar alg)
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let clamp a k = match a with | DH.DH_Curve25519 -> Spec.Curve25519.decodeScalar k
val clamp: alg:algorithm{alg = DH_Curve25519} -> scalar alg -> Tot (scalar alg) let clamp a k =
false
null
false
match a with | DH.DH_Curve25519 -> Spec.Curve25519.decodeScalar k
{ "checked_file": "Spec.Agile.DH.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.DH.fst" }
[ "total" ]
[ "Spec.Agile.DH.algorithm", "Prims.b2t", "Prims.op_Equality", "Spec.Agile.DH.DH_Curve25519", "Spec.Agile.DH.scalar", "Spec.Curve25519.decodeScalar" ]
[]
module Spec.Agile.DH open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants type algorithm = | DH_Curve25519 | DH_P256 inline_for_extraction let size_key (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 32 inline_for_extraction let size_public (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 64 inline_for_extraction let prime (a:algorithm) = match a with | DH_Curve25519 -> Spec.Curve25519.prime | DH_P256 -> Spec.P256.prime /// Types type scalar (a:algorithm) = lbytes (size_key a) type serialized_point (a:algorithm) = lbytes (size_public a) /// Functions val clamp: alg:algorithm{alg = DH_Curve25519} -> scalar alg -> Tot (scalar alg)
false
false
Spec.Agile.DH.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val clamp: alg:algorithm{alg = DH_Curve25519} -> scalar alg -> Tot (scalar alg)
[]
Spec.Agile.DH.clamp
{ "file_name": "specs/Spec.Agile.DH.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Spec.Agile.DH.algorithm{alg = Spec.Agile.DH.DH_Curve25519} -> k: Spec.Agile.DH.scalar alg -> Spec.Agile.DH.scalar alg
{ "end_col": 54, "end_line": 44, "start_col": 2, "start_line": 43 }
Prims.Tot
val size_key (a: algorithm) : Tot size_nat
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_key (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 32
val size_key (a: algorithm) : Tot size_nat let size_key (a: algorithm) : Tot size_nat =
false
null
false
match a with | DH_Curve25519 -> 32 | DH_P256 -> 32
{ "checked_file": "Spec.Agile.DH.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.DH.fst" }
[ "total" ]
[ "Spec.Agile.DH.algorithm", "Lib.IntTypes.size_nat" ]
[]
module Spec.Agile.DH open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants type algorithm = | DH_Curve25519 | DH_P256 inline_for_extraction
false
true
Spec.Agile.DH.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_key (a: algorithm) : Tot size_nat
[]
Spec.Agile.DH.size_key
{ "file_name": "specs/Spec.Agile.DH.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.DH.algorithm -> Lib.IntTypes.size_nat
{ "end_col": 17, "end_line": 19, "start_col": 2, "start_line": 17 }
Prims.Tot
val size_public (a: algorithm) : Tot size_nat
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_public (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 64
val size_public (a: algorithm) : Tot size_nat let size_public (a: algorithm) : Tot size_nat =
false
null
false
match a with | DH_Curve25519 -> 32 | DH_P256 -> 64
{ "checked_file": "Spec.Agile.DH.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.DH.fst" }
[ "total" ]
[ "Spec.Agile.DH.algorithm", "Lib.IntTypes.size_nat" ]
[]
module Spec.Agile.DH open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants type algorithm = | DH_Curve25519 | DH_P256 inline_for_extraction let size_key (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 32 inline_for_extraction
false
true
Spec.Agile.DH.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_public (a: algorithm) : Tot size_nat
[]
Spec.Agile.DH.size_public
{ "file_name": "specs/Spec.Agile.DH.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.DH.algorithm -> Lib.IntTypes.size_nat
{ "end_col": 17, "end_line": 25, "start_col": 2, "start_line": 23 }
Prims.Tot
val dh: a:algorithm -> s:scalar a -> p:serialized_point a -> Tot (option (serialized_point a))
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let dh a s p = match a with | DH_Curve25519 -> let output = Spec.Curve25519.scalarmult s p in let is_valid = not (lbytes_eq (create (size_public a) (u8 0)) output) in if is_valid then Some output else None | DH_P256 -> Spec.P256.ecdh p s
val dh: a:algorithm -> s:scalar a -> p:serialized_point a -> Tot (option (serialized_point a)) let dh a s p =
false
null
false
match a with | DH_Curve25519 -> let output = Spec.Curve25519.scalarmult s p in let is_valid = not (lbytes_eq (create (size_public a) (u8 0)) output) in if is_valid then Some output else None | DH_P256 -> Spec.P256.ecdh p s
{ "checked_file": "Spec.Agile.DH.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.DH.fst" }
[ "total" ]
[ "Spec.Agile.DH.algorithm", "Spec.Agile.DH.scalar", "Spec.Agile.DH.serialized_point", "FStar.Pervasives.Native.Some", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Prims.op_Negation", "Lib.ByteSequence.lbytes_eq", "Spec.Agile.DH.size_public", "Lib.Sequence.create", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.u8", "Spec.Curve25519.serialized_point", "Spec.Curve25519.scalarmult", "Spec.P256.ecdh" ]
[]
module Spec.Agile.DH open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants type algorithm = | DH_Curve25519 | DH_P256 inline_for_extraction let size_key (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 32 inline_for_extraction let size_public (a:algorithm) : Tot size_nat = match a with | DH_Curve25519 -> 32 | DH_P256 -> 64 inline_for_extraction let prime (a:algorithm) = match a with | DH_Curve25519 -> Spec.Curve25519.prime | DH_P256 -> Spec.P256.prime /// Types type scalar (a:algorithm) = lbytes (size_key a) type serialized_point (a:algorithm) = lbytes (size_public a) /// Functions val clamp: alg:algorithm{alg = DH_Curve25519} -> scalar alg -> Tot (scalar alg) let clamp a k = match a with | DH.DH_Curve25519 -> Spec.Curve25519.decodeScalar k #set-options "--z3rlimit 50" val dh: a:algorithm -> s:scalar a -> p:serialized_point a -> Tot (option (serialized_point a))
false
false
Spec.Agile.DH.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val dh: a:algorithm -> s:scalar a -> p:serialized_point a -> Tot (option (serialized_point a))
[]
Spec.Agile.DH.dh
{ "file_name": "specs/Spec.Agile.DH.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.DH.algorithm -> s: Spec.Agile.DH.scalar a -> p: Spec.Agile.DH.serialized_point a -> FStar.Pervasives.Native.option (Spec.Agile.DH.serialized_point a)
{ "end_col": 22, "end_line": 56, "start_col": 2, "start_line": 50 }
FStar.Pervasives.Lemma
val lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) [SMTPat (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s))]
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s)
val lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) [SMTPat (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s))] let lemma_reverse_reverse_bytes_nat32_seq (s: seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) =
false
null
true
reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s)
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat32", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Types_s.nat32", "Vale.Def.Types_s.reverse_bytes_nat32_seq", "Prims.unit", "Vale.Def.Types_s.reveal_reverse_bytes_nat32_seq", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) [SMTPat (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s))]
[]
Vale.Arch.Types.lemma_reverse_reverse_bytes_nat32_seq
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Words_s.nat32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.reverse_bytes_nat32_seq (Vale.Def.Types_s.reverse_bytes_nat32_seq s) == s) [ SMTPat (Vale.Def.Types_s.reverse_bytes_nat32_seq (Vale.Def.Types_s.reverse_bytes_nat32_seq s )) ]
{ "end_col": 72, "end_line": 111, "start_col": 2, "start_line": 109 }
FStar.Pervasives.Lemma
val lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) [SMTPat (reverse_bytes_nat32 (reverse_bytes_nat32 n))]
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; ()
val lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) [SMTPat (reverse_bytes_nat32 (reverse_bytes_nat32 n))] let lemma_reverse_reverse_bytes_nat32 (n: nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) =
false
null
true
reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Words_s.nat32", "Prims.unit", "Vale.Def.Types_s.be_bytes_to_nat32_to_be_bytes", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Vale.Lib.Seqs_s.reverse_seq", "Vale.Def.Types_s.nat8", "Vale.Def.Types_s.nat32_to_be_bytes", "Vale.Def.Types_s.reverse_bytes_nat32_reveal", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Def.Types_s.reverse_bytes_nat32", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) [SMTPat (reverse_bytes_nat32 (reverse_bytes_nat32 n))]
[]
Vale.Arch.Types.lemma_reverse_reverse_bytes_nat32
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Vale.Def.Words_s.nat32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.reverse_bytes_nat32 (Vale.Def.Types_s.reverse_bytes_nat32 n) == n) [SMTPat (Vale.Def.Types_s.reverse_bytes_nat32 (Vale.Def.Types_s.reverse_bytes_nat32 n))]
{ "end_col": 4, "end_line": 74, "start_col": 2, "start_line": 71 }
FStar.Pervasives.Lemma
val lemma_BitwiseXorCancel (n:nat32) : Lemma (n *^ n == 0)
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0
val lemma_BitwiseXorCancel (n:nat32) : Lemma (n *^ n == 0) let lemma_BitwiseXorCancel n =
false
null
true
lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Words_s.nat32", "Vale.Arch.TypesNative.lemma_equal_nth", "Vale.Arch.Types.op_Star_Hat", "Prims.unit", "Vale.Arch.TypesNative.lemma_zero_nth", "Vale.Arch.TypesNative.lemma_ixor_nth_all" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_BitwiseXorCancel (n:nat32) : Lemma (n *^ n == 0)
[]
Vale.Arch.Types.lemma_BitwiseXorCancel
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Vale.Def.Words_s.nat32 -> FStar.Pervasives.Lemma (ensures n *^ n == 0)
{ "end_col": 31, "end_line": 28, "start_col": 2, "start_line": 26 }
FStar.Pervasives.Lemma
val be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b')
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective()
val be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') let be_quad32_to_bytes_injective_specific (b b': quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') =
false
null
true
be_quad32_to_bytes_injective ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Vale.Arch.Types.be_quad32_to_bytes_injective", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.eq2", "Vale.Def.Words.Seq_s.seq16", "Vale.Def.Words_s.nat8", "Vale.Arch.Types.be_quad32_to_bytes", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b')
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b')
[]
Vale.Arch.Types.be_quad32_to_bytes_injective_specific
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.Def.Types_s.quad32 -> b': Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Arch.Types.be_quad32_to_bytes b == Vale.Arch.Types.be_quad32_to_bytes b' ==> b == b')
{ "end_col": 32, "end_line": 507, "start_col": 2, "start_line": 507 }
FStar.Pervasives.Lemma
val be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q)))
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; ()
val be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) let be_seq_quad32_to_bytes_of_singleton (q: quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) =
false
null
true
reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.Def.Words.Seq.four_to_seq_BE_is_seq_four_to_seq_BE", "FStar.Pervasives.reveal_opaque", "Vale.Def.Words.Seq_s.seq16", "Vale.Def.Words_s.nat8", "Vale.Arch.Types.be_quad32_to_bytes", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Seq.Base.seq", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Def.Words_s.nat32", "FStar.Seq.Base.create", "Vale.Def.Words_s.four", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q)))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q)))
[]
Vale.Arch.Types.be_seq_quad32_to_bytes_of_singleton
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Arch.Types.be_quad32_to_bytes q == Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE (FStar.Seq.Base.create 1 q)))
{ "end_col": 4, "end_line": 453, "start_col": 2, "start_line": 451 }
FStar.Pervasives.Lemma
val lemma_BitwiseXorCancel64 (n:nat64) : Lemma (ixor n n == 0)
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0
val lemma_BitwiseXorCancel64 (n:nat64) : Lemma (ixor n n == 0) let lemma_BitwiseXorCancel64 (n: nat64) =
false
null
true
lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Words_s.nat64", "Vale.Arch.TypesNative.lemma_equal_nth", "Vale.Def.Types_s.ixor", "Vale.Def.Words_s.pow2_64", "Prims.unit", "Vale.Arch.TypesNative.lemma_zero_nth", "Vale.Arch.TypesNative.lemma_ixor_nth_all" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_BitwiseXorCancel64 (n:nat64) : Lemma (ixor n n == 0)
[]
Vale.Arch.Types.lemma_BitwiseXorCancel64
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Vale.Def.Words_s.nat64 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.ixor n n == 0)
{ "end_col": 33, "end_line": 33, "start_col": 2, "start_line": 31 }
FStar.Pervasives.Lemma
val lemma_reverse_bytes_quad32 (q:quad32) : Lemma (reverse_bytes_quad32 (reverse_bytes_quad32 q) == q) [SMTPat (reverse_bytes_quad32 (reverse_bytes_quad32 q))]
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); ()
val lemma_reverse_bytes_quad32 (q:quad32) : Lemma (reverse_bytes_quad32 (reverse_bytes_quad32 q) == q) [SMTPat (reverse_bytes_quad32 (reverse_bytes_quad32 q))] let lemma_reverse_bytes_quad32 (q: quad32) =
false
null
true
quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.Def.Types_s.reveal_reverse_bytes_quad32", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.Def.Types_s.reverse_bytes_nat32_reveal", "Vale.Def.Types_s.quad32_xor_reveal" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this?
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 3, "initial_ifuel": 3, "max_fuel": 3, "max_ifuel": 3, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_reverse_bytes_quad32 (q:quad32) : Lemma (reverse_bytes_quad32 (reverse_bytes_quad32 q) == q) [SMTPat (reverse_bytes_quad32 (reverse_bytes_quad32 q))]
[]
Vale.Arch.Types.lemma_reverse_bytes_quad32
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 q) == q) [SMTPat (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.reverse_bytes_quad32 q))]
{ "end_col": 4, "end_line": 82, "start_col": 2, "start_line": 78 }
FStar.Pervasives.Lemma
val lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32).{:pattern hi64 q0; hi64 q1} (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1))
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; ()
val lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32).{:pattern hi64 q0; hi64 q1} (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) let lemma_hi64_properties (_: unit) : Lemma (forall (q0: quad32) (q1: quad32). (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) =
false
null
true
hi64_reveal (); let helper (q0 q1: quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.forall_intro_2", "Vale.Def.Types_s.quad32", "Prims.l_iff", "Prims.l_and", "Prims.eq2", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.nat64", "Vale.Arch.Types.hi64", "Prims.l_True", "Prims.squash", "Vale.Def.Words_s.nat32", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.Def.Words.Two.nat_to_two_to_nat", "Vale.Def.Words_s.two", "Vale.Def.Words.Two_s.two_select", "Vale.Def.Words.Four_s.four_to_two_two", "Vale.Arch.Types.hi64_reveal", "Prims.l_Forall" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32).{:pattern hi64 q0; hi64 q1} (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1))
[]
Vale.Arch.Types.lemma_hi64_properties
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (q0: Vale.Def.Types_s.quad32) (q1: Vale.Def.Types_s.quad32). {:pattern Vale.Arch.Types.hi64 q0; Vale.Arch.Types.hi64 q1} Mkfour?.hi2 q0 == Mkfour?.hi2 q1 /\ Mkfour?.hi3 q0 == Mkfour?.hi3 q1 <==> Vale.Arch.Types.hi64 q0 == Vale.Arch.Types.hi64 q1)
{ "end_col": 4, "end_line": 193, "start_col": 2, "start_line": 184 }
FStar.Pervasives.Lemma
val lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))]
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] = seq_map_inverses reverse_bytes_quad32 reverse_bytes_quad32 s
val lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] let lemma_reverse_reverse_bytes_quad32_seq (s: seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] =
false
null
true
seq_map_inverses reverse_bytes_quad32 reverse_bytes_quad32 s
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Lib.Seqs.seq_map_inverses", "Vale.Def.Types_s.reverse_bytes_quad32", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Arch.Types.reverse_bytes_quad32_seq", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE () let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] = seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s let lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))]
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))]
[]
Vale.Arch.Types.lemma_reverse_reverse_bytes_quad32_seq
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.Arch.Types.reverse_bytes_quad32_seq s) == s) [ SMTPat (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.Arch.Types.reverse_bytes_quad32_seq s )) ]
{ "end_col": 62, "end_line": 602, "start_col": 2, "start_line": 602 }
FStar.Pervasives.Lemma
val le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q))
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; ()
val le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) let le_seq_quad32_to_bytes_of_singleton (q: quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) =
false
null
true
le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.Def.Words.Seq.four_to_seq_LE_is_seq_four_to_seq_LE", "Vale.Def.Types_s.nat32", "FStar.Pervasives.reveal_opaque", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Prims.l_True", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "Vale.Def.Types_s.le_quad32_to_bytes", "Vale.Def.Types_s.le_seq_quad32_to_bytes_reveal", "Prims.squash", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "FStar.Seq.Base.create", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q))
[]
Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.le_quad32_to_bytes q == Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.create 1 q))
{ "end_col": 4, "end_line": 446, "start_col": 2, "start_line": 443 }
FStar.Pervasives.Lemma
val lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))]
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE ()
val lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] let lemma_reverse_reverse_bytes_nat32_quad32 (s: quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] =
false
null
true
let s' = reverse_bytes_nat32_quad32 s in let s'' = reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Prims._assert", "Prims.eq2", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Types_s.reverse_bytes_nat32", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Arch.Types.reverse_bytes_nat32_quad32", "Prims.l_True", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))]
[]
Vale.Arch.Types.lemma_reverse_reverse_bytes_nat32_quad32
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Arch.Types.reverse_bytes_nat32_quad32 (Vale.Arch.Types.reverse_bytes_nat32_quad32 s) == s) [ SMTPat (Vale.Arch.Types.reverse_bytes_nat32_quad32 (Vale.Arch.Types.reverse_bytes_nat32_quad32 s)) ]
{ "end_col": 4, "end_line": 590, "start_col": 3, "start_line": 583 }
FStar.Pervasives.Lemma
val lemma_BitwiseXorWithZero (n:nat32) : Lemma (n *^ 0 == n)
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n
val lemma_BitwiseXorWithZero (n:nat32) : Lemma (n *^ 0 == n) let lemma_BitwiseXorWithZero n =
false
null
true
lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Words_s.nat32", "Vale.Arch.TypesNative.lemma_equal_nth", "Vale.Arch.Types.op_Star_Hat", "Prims.unit", "Vale.Arch.TypesNative.lemma_zero_nth", "Vale.Arch.TypesNative.lemma_ixor_nth_all" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_BitwiseXorWithZero (n:nat32) : Lemma (n *^ 0 == n)
[]
Vale.Arch.Types.lemma_BitwiseXorWithZero
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Vale.Def.Words_s.nat32 -> FStar.Pervasives.Lemma (ensures n *^ 0 == n)
{ "end_col": 31, "end_line": 23, "start_col": 2, "start_line": 21 }
FStar.Pervasives.Lemma
val lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) [SMTPat (insert_nat64 q n)]
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); ()
val lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) [SMTPat (insert_nat64 q n)] let lemma_insert_nat64_properties (q: quad32) (n: nat64) : Lemma ((let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) =
false
null
true
insert_nat64_reveal (); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Vale.Def.Words_s.nat64", "Prims.unit", "Vale.Def.Types_s.insert_nat64_reveal", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.eq2", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Types_s.insert_nat64", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) [SMTPat (insert_nat64 q n)]
[]
Vale.Arch.Types.lemma_insert_nat64_properties
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> n: Vale.Def.Words_s.nat64 -> FStar.Pervasives.Lemma (ensures (let q' = Vale.Def.Types_s.insert_nat64 q n 0 in Mkfour?.hi2 q' == Mkfour?.hi2 q /\ Mkfour?.hi3 q' == Mkfour?.hi3 q) /\ (let q' = Vale.Def.Types_s.insert_nat64 q n 1 in Mkfour?.lo0 q' == Mkfour?.lo0 q /\ Mkfour?.lo1 q' == Mkfour?.lo1 q)) [SMTPat (Vale.Def.Types_s.insert_nat64 q n)]
{ "end_col": 4, "end_line": 155, "start_col": 2, "start_line": 154 }
FStar.Pervasives.Lemma
val lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z)
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; ()
val lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) let lemma_reverse_bytes_quad32_zero (_: unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) =
false
null
true
let z = Mkfour 0 0 0 0 in calc ( == ) { reverse_bytes_quad32 z; ( == ) { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); ( == ) { lemma_reverse_bytes_nat32 () } z; }; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Calc.calc_finish", "Vale.Def.Types_s.quad32", "Prims.eq2", "Vale.Def.Types_s.reverse_bytes_quad32", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Vale.Def.Words.Four_s.four_reverse", "Vale.Def.Types_s.nat32", "Vale.Def.Words.Four_s.four_map", "Vale.Def.Types_s.reverse_bytes_nat32", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Vale.Def.Types_s.reveal_reverse_bytes_quad32", "Prims.squash", "Vale.Arch.Types.lemma_reverse_bytes_nat32", "Vale.Def.Words_s.four", "Vale.Def.Words_s.nat32", "Vale.Def.Words_s.Mkfour", "Prims.l_True", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z)
[]
Vale.Arch.Types.lemma_reverse_bytes_quad32_zero
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures (let z = Vale.Def.Words_s.Mkfour 0 0 0 0 in Vale.Def.Types_s.reverse_bytes_quad32 z == z))
{ "end_col": 4, "end_line": 104, "start_col": 3, "start_line": 95 }
FStar.Pervasives.Lemma
val le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b')
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective()
val le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') let le_quad32_to_bytes_injective_specific (b b': quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') =
false
null
true
le_quad32_to_bytes_injective ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Vale.Arch.Types.le_quad32_to_bytes_injective", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.eq2", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.Def.Types_s.le_quad32_to_bytes", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b')
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b')
[]
Vale.Arch.Types.le_quad32_to_bytes_injective_specific
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Vale.Def.Types_s.quad32 -> b': Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.le_quad32_to_bytes b == Vale.Def.Types_s.le_quad32_to_bytes b' ==> b == b')
{ "end_col": 32, "end_line": 502, "start_col": 2, "start_line": 502 }
FStar.Pervasives.Lemma
val seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s)
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); ()
val seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) let seq_to_four_BE_is_seq_to_seq_four_BE (#a: Type) (s: seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) =
false
null
true
reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Words.Seq_s.seq4", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words_s.four", "FStar.Seq.Base.create", "Vale.Def.Words.Seq_s.seq_to_four_BE", "Vale.Def.Words.Seq_s.seq_to_seq_four_BE", "FStar.Pervasives.reveal_opaque", "FStar.Seq.Base.seq", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.op_Division", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s)
[]
Vale.Arch.Types.seq_to_four_BE_is_seq_to_seq_four_BE
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.Def.Words.Seq_s.seq4 a -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.create 1 (Vale.Def.Words.Seq_s.seq_to_four_BE s) == Vale.Def.Words.Seq_s.seq_to_seq_four_BE s)
{ "end_col": 4, "end_line": 529, "start_col": 2, "start_line": 527 }
FStar.Pervasives.Lemma
val lemma_quad32_xor (_:unit) : Lemma (forall q . {:pattern quad32_xor q q} quad32_xor q q == Mkfour 0 0 0 0)
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas()
val lemma_quad32_xor (_:unit) : Lemma (forall q . {:pattern quad32_xor q q} quad32_xor q q == Mkfour 0 0 0 0) let lemma_quad32_xor () =
false
null
true
quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Prims.unit", "Vale.Arch.Types.xor_lemmas", "Vale.Def.Types_s.reverse_bytes_nat32_reveal", "Vale.Def.Types_s.quad32_xor_reveal" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this?
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 3, "initial_ifuel": 3, "max_fuel": 3, "max_ifuel": 3, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_quad32_xor (_:unit) : Lemma (forall q . {:pattern quad32_xor q q} quad32_xor q q == Mkfour 0 0 0 0)
[]
Vale.Arch.Types.lemma_quad32_xor
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (q: Vale.Def.Types_s.quad32). {:pattern Vale.Def.Types_s.quad32_xor q q} Vale.Def.Types_s.quad32_xor q q == Vale.Def.Words_s.Mkfour 0 0 0 0)
{ "end_col": 14, "end_line": 51, "start_col": 2, "start_line": 49 }
FStar.Pervasives.Lemma
val slice_commutes_be_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) 0 (n * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s 0 n)))
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let slice_commutes_be_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) 0 (n * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s 0 n))) = slice_commutes_be_seq_quad32_to_bytes s 0 n
val slice_commutes_be_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) 0 (n * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s 0 n))) let slice_commutes_be_seq_quad32_to_bytes0 (s: seq quad32) (n: nat{n <= length s}) : Lemma (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) 0 (n * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s 0 n))) =
false
null
true
slice_commutes_be_seq_quad32_to_bytes s 0 n
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Vale.Arch.Types.slice_commutes_be_seq_quad32_to_bytes", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Def.Words_s.nat8", "FStar.Seq.Base.slice", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Def.Types_s.nat32", "FStar.Mul.op_Star", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE () let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] = seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s let lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] = seq_map_inverses reverse_bytes_quad32 reverse_bytes_quad32 s let lemma_le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (le_seq_quad32_to_bytes s) == (length s) * 16) = () let lemma_be_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == (length s) * 16) = () let slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) (seq_four_to_seq_LE (slice s n n'))); () let slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); assert (equal (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4)) (seq_four_to_seq_BE (slice s n n'))); () let slice_commutes_le_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n')) = le_seq_quad32_to_bytes_reveal (); slice_commutes_seq_four_to_seq_LE s n n'; assert (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')); (* le_seq_quad32_to_bytes (slice s n n') == seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE (slice s n n'))); == seq_four_to_seq_LE (seq_map (nat_to_four 8) (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))) (n * 16) (n' * 16) == seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) (n * 4) (n' * 4)) *) slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_LE s) (n*4) (n'*4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) in slice_commutes_seq_four_to_seq_LE s_inner (n * 4) (n' * 4); () let slice_commutes_be_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) (n * 16) (n' * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s n n'))) = slice_commutes_seq_four_to_seq_BE s n n'; assert (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')); slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_BE s) (n*4) (n'*4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)) in slice_commutes_seq_four_to_seq_BE s_inner (n * 4) (n' * 4); () let slice_commutes_le_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) 0 (n * 16) == le_seq_quad32_to_bytes (slice s 0 n)) = slice_commutes_le_seq_quad32_to_bytes s 0 n let slice_commutes_be_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) 0 (n * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s 0 n)))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val slice_commutes_be_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) 0 (n * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s 0 n)))
[]
Vale.Arch.Types.slice_commutes_be_seq_quad32_to_bytes0
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> n: Prims.nat{n <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE s)) 0 (n * 16) == Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE (FStar.Seq.Base.slice s 0 n)))
{ "end_col": 45, "end_line": 674, "start_col": 2, "start_line": 674 }
FStar.Pervasives.Lemma
val le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s)
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; ()
val le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) let le_bytes_to_seq_quad32_to_bytes (s: seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) =
false
null
true
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.Def.Words.Seq.seq_to_seq_four_to_seq_LE", "Vale.Def.Types_s.nat32", "Vale.Lib.Seqs.seq_map_inverses", "Vale.Def.Words_s.four", "Vale.Def.Words_s.natN", "Prims.pow2", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Seq_s.seq_four_to_seq_LE", "Vale.Lib.Seqs_s.seq_map", "Vale.Def.Types_s.le_seq_quad32_to_bytes_reveal", "FStar.Pervasives.reveal_opaque", "Vale.Def.Types_s.nat8", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.l_True", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Prims.squash", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s)
[]
Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.le_bytes_to_seq_quad32 (Vale.Def.Types_s.le_seq_quad32_to_bytes s) == s)
{ "end_col": 4, "end_line": 380, "start_col": 2, "start_line": 375 }
FStar.Pervasives.Lemma
val le_seq_quad32_to_bytes_injective (b b':Seq.seq quad32) : Lemma (requires Seq.equal (le_seq_quad32_to_bytes b) (le_seq_quad32_to_bytes b')) (ensures b == b')
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b')
val le_seq_quad32_to_bytes_injective (b b':Seq.seq quad32) : Lemma (requires Seq.equal (le_seq_quad32_to_bytes b) (le_seq_quad32_to_bytes b')) (ensures b == b') let le_seq_quad32_to_bytes_injective (b b': seq quad32) =
false
null
true
le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective (); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b')
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims._assert", "FStar.Seq.Base.equal", "Prims.unit", "Vale.Def.Words.Seq.seq_four_to_seq_LE_injective_specific", "Vale.Def.Types_s.nat32", "Vale.Lib.Seqs.seq_map_injective", "Vale.Def.Words_s.four", "Vale.Def.Words_s.natN", "Prims.pow2", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Seq_s.seq_four_to_seq_LE", "Vale.Def.Words.Seq.nat_to_four_8_injective", "Vale.Def.Words.Seq.seq_four_to_seq_LE_injective", "Vale.Def.Words_s.nat8", "Vale.Def.Types_s.le_seq_quad32_to_bytes_reveal" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective()
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_seq_quad32_to_bytes_injective (b b':Seq.seq quad32) : Lemma (requires Seq.equal (le_seq_quad32_to_bytes b) (le_seq_quad32_to_bytes b')) (ensures b == b')
[]
Vale.Arch.Types.le_seq_quad32_to_bytes_injective
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> b': FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.equal (Vale.Def.Types_s.le_seq_quad32_to_bytes b) (Vale.Def.Types_s.le_seq_quad32_to_bytes b')) (ensures b == b')
{ "end_col": 21, "end_line": 515, "start_col": 2, "start_line": 510 }
FStar.Pervasives.Lemma
val le_bytes_to_seq_quad32_empty: unit -> Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0)
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; ()
val le_bytes_to_seq_quad32_empty: unit -> Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) let le_bytes_to_seq_quad32_empty () : Lemma (forall s. {:pattern (length (le_bytes_to_seq_quad32 s))} length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) =
false
null
true
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Pervasives.reveal_opaque", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.Def.Types_s.quad32", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.l_True", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 3, "initial_ifuel": 3, "max_fuel": 3, "max_ifuel": 3, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_bytes_to_seq_quad32_empty: unit -> Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0)
[]
Vale.Arch.Types.le_bytes_to_seq_quad32_empty
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (s: FStar.Seq.Base.seq Vale.Def.Types_s.nat8). {:pattern FStar.Seq.Base.length (Vale.Def.Types_s.le_bytes_to_seq_quad32 s)} FStar.Seq.Base.length s == 0 ==> FStar.Seq.Base.length (Vale.Def.Types_s.le_bytes_to_seq_quad32 s) == 0)
{ "end_col": 4, "end_line": 314, "start_col": 2, "start_line": 313 }
FStar.Pervasives.Lemma
val lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3))
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); ()
val lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) let lemma_insrq_extrq_relations (x y: quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) =
false
null
true
let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.Def.Words.Two.nat_to_two_to_nat", "Vale.Def.Words_s.two", "Vale.Def.Words_s.nat32", "Vale.Def.Words.Two_s.two_select", "Vale.Def.Words.Four_s.four_to_two_two", "Prims._assert", "Prims.eq2", "Vale.Def.Types_s.insert_nat64_def", "Vale.Arch.Types.lo64_def", "Vale.Arch.Types.hi64_reveal", "Vale.Arch.Types.lo64_reveal", "Vale.Def.Types_s.insert_nat64_reveal", "Vale.Def.Types_s.insert_nat64", "Vale.Arch.Types.lo64", "Prims.l_True", "Prims.squash", "Prims.l_and", "Vale.Def.Words_s.four", "Vale.Def.Words_s.Mkfour", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Arch.Types.hi64", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 3, "initial_ifuel": 3, "max_fuel": 3, "max_ifuel": 3, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3))
[]
Vale.Arch.Types.lemma_insrq_extrq_relations
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.quad32 -> y: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures (let z = Vale.Def.Types_s.insert_nat64 x (Vale.Arch.Types.lo64 y) 0 in z == Vale.Def.Words_s.Mkfour (Mkfour?.lo0 y) (Mkfour?.lo1 y) (Mkfour?.hi2 x) (Mkfour?.hi3 x) /\ (let z = Vale.Def.Types_s.insert_nat64 x (Vale.Arch.Types.hi64 y) 1 in z == Vale.Def.Words_s.Mkfour (Mkfour?.lo0 x) (Mkfour?.lo1 x) (Mkfour?.hi2 y) (Mkfour?.hi3 y))))
{ "end_col": 4, "end_line": 297, "start_col": 2, "start_line": 280 }
FStar.Pervasives.Lemma
val le_bytes_to_nat64_to_bytes (s:nat64) : Lemma (le_bytes_to_nat64 (le_nat64_to_bytes s) == s)
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal ()
val le_bytes_to_nat64_to_bytes (s:nat64) : Lemma (le_bytes_to_nat64 (le_nat64_to_bytes s) == s) let le_bytes_to_nat64_to_bytes s =
false
null
true
le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Words_s.nat64", "Vale.Def.Types_s.le_bytes_to_nat64_reveal", "Prims.unit", "Vale.Def.Types_s.le_nat64_to_bytes_reveal" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 3, "initial_ifuel": 3, "max_fuel": 3, "max_ifuel": 3, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_bytes_to_nat64_to_bytes (s:nat64) : Lemma (le_bytes_to_nat64 (le_nat64_to_bytes s) == s)
[]
Vale.Arch.Types.le_bytes_to_nat64_to_bytes
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.Def.Words_s.nat64 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.le_bytes_to_nat64 (Vale.Def.Types_s.le_nat64_to_bytes s) == s)
{ "end_col": 29, "end_line": 303, "start_col": 2, "start_line": 302 }
FStar.Pervasives.Lemma
val lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32).{:pattern lo64 q0; lo64 q1} (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1))
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; ()
val lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32).{:pattern lo64 q0; lo64 q1} (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) let lemma_lo64_properties (_: unit) : Lemma (forall (q0: quad32) (q1: quad32). (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) =
false
null
true
lo64_reveal (); let helper (q0 q1: quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.forall_intro_2", "Vale.Def.Types_s.quad32", "Prims.l_iff", "Prims.l_and", "Prims.eq2", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.nat64", "Vale.Arch.Types.lo64", "Prims.l_True", "Prims.squash", "Vale.Def.Words_s.nat32", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.Def.Words.Two.nat_to_two_to_nat", "Vale.Def.Words_s.two", "Vale.Def.Words.Two_s.two_select", "Vale.Def.Words.Four_s.four_to_two_two", "Vale.Arch.Types.lo64_reveal", "Prims.l_Forall" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32).{:pattern lo64 q0; lo64 q1} (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1))
[]
Vale.Arch.Types.lemma_lo64_properties
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (q0: Vale.Def.Types_s.quad32) (q1: Vale.Def.Types_s.quad32). {:pattern Vale.Arch.Types.lo64 q0; Vale.Arch.Types.lo64 q1} Mkfour?.lo0 q0 == Mkfour?.lo0 q1 /\ Mkfour?.lo1 q0 == Mkfour?.lo1 q1 <==> Vale.Arch.Types.lo64 q0 == Vale.Arch.Types.lo64 q1)
{ "end_col": 4, "end_line": 179, "start_col": 2, "start_line": 170 }
FStar.Pervasives.Lemma
val lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 )
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); ()
val lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) let lemma_insert_nat64_nat32s (q: quad32) (n0 n1: nat32) : Lemma (insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1) =
false
null
true
let open Vale.Def.Words.Two in insert_nat64_reveal (); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Vale.Def.Words_s.nat32", "Prims.unit", "Vale.Def.Types_s.insert_nat64_reveal", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.eq2", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat32", "Vale.Def.Types_s.insert_nat64", "Vale.Arch.Types.two_to_nat32", "Vale.Def.Words_s.Mktwo", "Vale.Def.Words_s.Mkfour", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 )
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 )
[]
Vale.Arch.Types.lemma_insert_nat64_nat32s
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> n0: Vale.Def.Words_s.nat32 -> n1: Vale.Def.Words_s.nat32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.insert_nat64 q (Vale.Arch.Types.two_to_nat32 (Vale.Def.Words_s.Mktwo n0 n1)) 0 == Vale.Def.Words_s.Mkfour n0 n1 (Mkfour?.hi2 q) (Mkfour?.hi3 q) /\ Vale.Def.Types_s.insert_nat64 q (Vale.Arch.Types.two_to_nat32 (Vale.Def.Words_s.Mktwo n0 n1)) 1 == Vale.Def.Words_s.Mkfour (Mkfour?.lo0 q) (Mkfour?.lo1 q) n0 n1)
{ "end_col": 4, "end_line": 165, "start_col": 2, "start_line": 163 }
FStar.Pervasives.Lemma
val be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) [SMTPat (be_bytes_to_quad32 (be_quad32_to_bytes q))]
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; ()
val be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) [SMTPat (be_bytes_to_quad32 (be_quad32_to_bytes q))] let be_bytes_to_quad32_to_bytes (q: quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) =
false
null
true
be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.Def.Words.Seq.seq_to_four_to_seq_BE", "Vale.Def.Types_s.nat32", "Vale.Lib.Seqs.seq_map_inverses", "Vale.Def.Words_s.four", "Vale.Def.Words_s.natN", "Prims.pow2", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Seq_s.four_to_seq_BE", "Vale.Def.Words.Seq.seq_to_seq_four_to_seq_BE", "Vale.Lib.Seqs_s.seq_map", "Vale.Def.Types_s.be_bytes_to_quad32", "Vale.Arch.Types.be_quad32_to_bytes", "Vale.Def.Types_s.be_bytes_to_quad32_reveal", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) [SMTPat (be_bytes_to_quad32 (be_quad32_to_bytes q))]
[]
Vale.Arch.Types.be_bytes_to_quad32_to_bytes
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.be_bytes_to_quad32 (Vale.Arch.Types.be_quad32_to_bytes q) == q) [SMTPat (Vale.Def.Types_s.be_bytes_to_quad32 (Vale.Arch.Types.be_quad32_to_bytes q))]
{ "end_col": 4, "end_line": 578, "start_col": 2, "start_line": 573 }
FStar.Pervasives.Lemma
val slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n'))
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); assert (equal (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4)) (seq_four_to_seq_BE (slice s n n'))); ()
val slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')) let slice_commutes_seq_four_to_seq_BE (#a: Type) (s: seq (four a)) (n: nat{n <= length s}) (n': nat{n <= n' /\ n' <= length s}) : Lemma (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')) =
false
null
true
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); assert (equal (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4)) (seq_four_to_seq_BE (slice s n n'))); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.four", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.l_and", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "FStar.Mul.op_Star", "FStar.Pervasives.reveal_opaque", "Prims.eq2", "Prims.int", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE () let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] = seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s let lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] = seq_map_inverses reverse_bytes_quad32 reverse_bytes_quad32 s let lemma_le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (le_seq_quad32_to_bytes s) == (length s) * 16) = () let lemma_be_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == (length s) * 16) = () let slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) (seq_four_to_seq_LE (slice s n n'))); () let slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n'))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n'))
[]
Vale.Arch.Types.slice_commutes_seq_four_to_seq_BE
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> n: Prims.nat{n <= FStar.Seq.Base.length s} -> n': Prims.nat{n <= n' /\ n' <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_four_to_seq_BE s) (n * 4) (n' * 4) == Vale.Def.Words.Seq_s.seq_four_to_seq_BE (FStar.Seq.Base.slice s n n'))
{ "end_col": 4, "end_line": 630, "start_col": 2, "start_line": 627 }
FStar.Pervasives.Lemma
val lemma_nat_to_two32 (_:unit) : Lemma (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000))
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000))
val lemma_nat_to_two32 (_:unit) : Lemma (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_nat_to_two32 () =
false
null
true
assert_norm (forall (x: nat64). {:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000))
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.l_Forall", "Vale.Def.Words_s.nat64", "Prims.eq2", "Vale.Def.Words_s.two", "Vale.Def.Words_s.natN", "Prims.pow2", "Vale.Def.Words.Two_s.nat_to_two", "Vale.Def.Words_s.Mktwo", "Prims.op_Modulus", "Prims.op_Division" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_nat_to_two32 (_:unit) : Lemma (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000))
[]
Vale.Arch.Types.lemma_nat_to_two32
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (x: Vale.Def.Words_s.nat64). {:pattern Vale.Def.Words.Two_s.nat_to_two 32 x} Vale.Def.Words.Two_s.nat_to_two 32 x == Vale.Def.Words_s.Mktwo (x % 0x100000000) (x / 0x100000000))
{ "end_col": 65, "end_line": 14, "start_col": 2, "start_line": 13 }
FStar.Pervasives.Lemma
val lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))]
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] = seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s
val lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] let lemma_reverse_reverse_bytes_nat32_quad32_seq (s: seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] =
false
null
true
seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Lib.Seqs.seq_map_inverses", "Vale.Arch.Types.reverse_bytes_nat32_quad32", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Arch.Types.reverse_bytes_nat32_quad32_seq", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE () let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))]
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))]
[]
Vale.Arch.Types.lemma_reverse_reverse_bytes_nat32_quad32_seq
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Arch.Types.reverse_bytes_nat32_quad32_seq (Vale.Arch.Types.reverse_bytes_nat32_quad32_seq s) == s) [ SMTPat (Vale.Arch.Types.reverse_bytes_nat32_quad32_seq (Vale.Arch.Types.reverse_bytes_nat32_quad32_seq s)) ]
{ "end_col": 74, "end_line": 596, "start_col": 2, "start_line": 596 }
FStar.Pervasives.Lemma
val be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s)
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; ()
val be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) let be_bytes_to_seq_quad32_to_bytes (s: seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) =
false
null
true
reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.Def.Words.Seq.seq_to_seq_four_to_seq_BE", "Vale.Def.Types_s.nat32", "Vale.Lib.Seqs.seq_map_inverses", "Vale.Def.Words_s.four", "Vale.Def.Words_s.natN", "Prims.pow2", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Lib.Seqs_s.seq_map", "FStar.Pervasives.reveal_opaque", "Vale.Def.Types_s.nat8", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.l_True", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Prims.squash", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s)
[]
Vale.Arch.Types.be_bytes_to_seq_quad32_to_bytes
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.be_bytes_to_seq_quad32 (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE s)) == s)
{ "end_col": 4, "end_line": 389, "start_col": 2, "start_line": 385 }
FStar.Pervasives.Lemma
val seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s)
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); ()
val seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) let seq_to_four_LE_is_seq_to_seq_four_LE (#a: Type) (s: seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) =
false
null
true
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Words.Seq_s.seq4", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words_s.four", "FStar.Seq.Base.create", "Vale.Def.Words.Seq_s.seq_to_four_LE", "Vale.Def.Words.Seq_s.seq_to_seq_four_LE", "FStar.Pervasives.reveal_opaque", "FStar.Seq.Base.seq", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.op_Division", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s)
[]
Vale.Arch.Types.seq_to_four_LE_is_seq_to_seq_four_LE
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.Def.Words.Seq_s.seq4 a -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.create 1 (Vale.Def.Words.Seq_s.seq_to_four_LE s) == Vale.Def.Words.Seq_s.seq_to_seq_four_LE s)
{ "end_col": 4, "end_line": 522, "start_col": 2, "start_line": 520 }
FStar.Pervasives.Lemma
val le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q)
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); ()
val le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) let le_bytes_to_quad32_to_bytes (q: quad32) : Lemma (le_bytes_to_quad32 (le_quad32_to_bytes q) == q) =
false
null
true
le_seq_quad32_to_bytes_of_singleton q; let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; le_bytes_to_seq_quad32_to_bytes (create 1 q); assert (q == index (create 1 q) 0); assert (q == q'); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.index", "FStar.Seq.Base.create", "Vale.Arch.Types.le_bytes_to_seq_quad32_to_bytes", "Vale.Arch.Types.le_bytes_to_seq_quad_of_singleton", "Vale.Def.Types_s.le_bytes_to_quad32", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Vale.Def.Types_s.le_quad32_to_bytes", "Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q)
[]
Vale.Arch.Types.le_bytes_to_quad32_to_bytes
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.le_bytes_to_quad32 (Vale.Def.Types_s.le_quad32_to_bytes q) == q)
{ "end_col": 4, "end_line": 568, "start_col": 2, "start_line": 558 }
FStar.Pervasives.Lemma
val be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b)
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); ()
val be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) let be_bytes_to_seq_quad_of_singleton (q: quad32) (b: seq nat8 {length b == 16}) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) =
false
null
true
reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "Prims.unit", "Vale.Arch.Types.seq_to_four_BE_is_seq_to_seq_four_BE", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Lib.Seqs_s.seq_map", "Vale.Def.Words_s.four", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Seq_s.seq_to_seq_four_BE", "Vale.Def.Types_s.be_bytes_to_quad32_reveal", "FStar.Pervasives.reveal_opaque", "Vale.Def.Types_s.nat8", "Prims.op_Modulus", "Prims.l_True", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Vale.Def.Types_s.be_bytes_to_quad32", "Prims.squash", "FStar.Seq.Base.create", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b)
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b)
[]
Vale.Arch.Types.be_bytes_to_seq_quad_of_singleton
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> b: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 {FStar.Seq.Base.length b == 16} -> FStar.Pervasives.Lemma (requires q == Vale.Def.Types_s.be_bytes_to_quad32 b) (ensures FStar.Seq.Base.create 1 q == Vale.Def.Types_s.be_bytes_to_seq_quad32 b)
{ "end_col": 4, "end_line": 553, "start_col": 2, "start_line": 550 }
FStar.Pervasives.Lemma
val slice_commutes_le_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) 0 (n * 16) == le_seq_quad32_to_bytes (slice s 0 n))
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let slice_commutes_le_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) 0 (n * 16) == le_seq_quad32_to_bytes (slice s 0 n)) = slice_commutes_le_seq_quad32_to_bytes s 0 n
val slice_commutes_le_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) 0 (n * 16) == le_seq_quad32_to_bytes (slice s 0 n)) let slice_commutes_le_seq_quad32_to_bytes0 (s: seq quad32) (n: nat{n <= length s}) : Lemma (slice (le_seq_quad32_to_bytes s) 0 (n * 16) == le_seq_quad32_to_bytes (slice s 0 n)) =
false
null
true
slice_commutes_le_seq_quad32_to_bytes s 0 n
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Vale.Arch.Types.slice_commutes_le_seq_quad32_to_bytes", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Def.Types_s.nat8", "FStar.Seq.Base.slice", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "FStar.Mul.op_Star", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE () let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] = seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s let lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] = seq_map_inverses reverse_bytes_quad32 reverse_bytes_quad32 s let lemma_le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (le_seq_quad32_to_bytes s) == (length s) * 16) = () let lemma_be_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == (length s) * 16) = () let slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) (seq_four_to_seq_LE (slice s n n'))); () let slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); assert (equal (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4)) (seq_four_to_seq_BE (slice s n n'))); () let slice_commutes_le_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n')) = le_seq_quad32_to_bytes_reveal (); slice_commutes_seq_four_to_seq_LE s n n'; assert (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')); (* le_seq_quad32_to_bytes (slice s n n') == seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE (slice s n n'))); == seq_four_to_seq_LE (seq_map (nat_to_four 8) (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))) (n * 16) (n' * 16) == seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) (n * 4) (n' * 4)) *) slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_LE s) (n*4) (n'*4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) in slice_commutes_seq_four_to_seq_LE s_inner (n * 4) (n' * 4); () let slice_commutes_be_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) (n * 16) (n' * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s n n'))) = slice_commutes_seq_four_to_seq_BE s n n'; assert (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')); slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_BE s) (n*4) (n'*4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)) in slice_commutes_seq_four_to_seq_BE s_inner (n * 4) (n' * 4); () let slice_commutes_le_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) 0 (n * 16) == le_seq_quad32_to_bytes (slice s 0 n))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val slice_commutes_le_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) 0 (n * 16) == le_seq_quad32_to_bytes (slice s 0 n))
[]
Vale.Arch.Types.slice_commutes_le_seq_quad32_to_bytes0
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> n: Prims.nat{n <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes s) 0 (n * 16) == Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.slice s 0 n))
{ "end_col": 45, "end_line": 668, "start_col": 2, "start_line": 668 }
FStar.Pervasives.Lemma
val le_nat64_to_bytes_to_nat64 (s:seq nat8 { length s == 8 }) : Lemma (le_nat64_to_bytes (le_bytes_to_nat64 s) == s)
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal ()
val le_nat64_to_bytes_to_nat64 (s:seq nat8 { length s == 8 }) : Lemma (le_nat64_to_bytes (le_bytes_to_nat64 s) == s) let le_nat64_to_bytes_to_nat64 n =
false
null
true
le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "Vale.Def.Types_s.le_bytes_to_nat64_reveal", "Prims.unit", "Vale.Def.Types_s.le_nat64_to_bytes_reveal" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal ()
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 3, "initial_ifuel": 3, "max_fuel": 3, "max_ifuel": 3, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_nat64_to_bytes_to_nat64 (s:seq nat8 { length s == 8 }) : Lemma (le_nat64_to_bytes (le_bytes_to_nat64 s) == s)
[]
Vale.Arch.Types.le_nat64_to_bytes_to_nat64
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 {FStar.Seq.Base.length s == 8} -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.le_nat64_to_bytes (Vale.Def.Types_s.le_bytes_to_nat64 s) == s)
{ "end_col": 29, "end_line": 307, "start_col": 2, "start_line": 306 }
FStar.Pervasives.Lemma
val le_quad32_to_bytes_injective: unit -> Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b')
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper
val le_quad32_to_bytes_injective: unit -> Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') let le_quad32_to_bytes_injective () : Lemma (forall b b'. le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') =
false
null
true
reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b': quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then (let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective (); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; ()) in FStar.Classical.forall_intro_2 helper
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.forall_intro_2", "Vale.Def.Types_s.quad32", "Prims.l_imp", "Prims.eq2", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.Def.Types_s.le_quad32_to_bytes", "Prims.l_True", "Prims.squash", "Vale.Def.Words_s.nat8", "Prims.Nil", "FStar.Pervasives.pattern", "Prims.op_Equality", "Vale.Def.Words.Seq.four_to_seq_LE_injective", "Vale.Def.Words_s.nat32", "Prims._assert", "Vale.Def.Words.Seq_s.seq4", "Vale.Def.Types_s.nat32", "Vale.Def.Words.Seq_s.four_to_seq_LE", "Vale.Lib.Seqs.seq_map_injective", "Vale.Def.Words_s.four", "Vale.Def.Words_s.natN", "Prims.pow2", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Seq.nat_to_four_8_injective", "Vale.Def.Words.Seq.seq_four_to_seq_LE_injective_specific", "Vale.Def.Words.Seq_s.seq_four_to_seq_LE", "Vale.Lib.Seqs_s.seq_map", "Prims.bool", "FStar.Pervasives.reveal_opaque", "Prims.int", "FStar.Seq.Base.length", "Prims.l_Forall" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b')
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_quad32_to_bytes_injective: unit -> Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b')
[]
Vale.Arch.Types.le_quad32_to_bytes_injective
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (b: Vale.Def.Types_s.quad32) (b': Vale.Def.Types_s.quad32). Vale.Def.Types_s.le_quad32_to_bytes b == Vale.Def.Types_s.le_quad32_to_bytes b' ==> b == b')
{ "end_col": 39, "end_line": 475, "start_col": 2, "start_line": 458 }
FStar.Pervasives.Lemma
val push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x')
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); ()
val push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') let push_pop_xmm (x y: quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') =
false
null
true
insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Vale.Arch.Types.hi64_reveal", "Vale.Arch.Types.lo64_reveal", "Vale.Def.Types_s.insert_nat64_reveal", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Def.Types_s.insert_nat64", "Vale.Arch.Types.hi64", "Vale.Arch.Types.lo64", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') =
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x')
[]
Vale.Arch.Types.push_pop_xmm
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.quad32 -> y: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures (let x' = Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 y (Vale.Arch.Types.hi64 x) 1) (Vale.Arch.Types.lo64 x) 0 in x == x'))
{ "end_col": 4, "end_line": 271, "start_col": 2, "start_line": 268 }
FStar.Pervasives.Lemma
val slice_commutes_le_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n'))
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let slice_commutes_le_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n')) = le_seq_quad32_to_bytes_reveal (); slice_commutes_seq_four_to_seq_LE s n n'; assert (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')); (* le_seq_quad32_to_bytes (slice s n n') == seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE (slice s n n'))); == seq_four_to_seq_LE (seq_map (nat_to_four 8) (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))) (n * 16) (n' * 16) == seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) (n * 4) (n' * 4)) *) slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_LE s) (n*4) (n'*4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) in slice_commutes_seq_four_to_seq_LE s_inner (n * 4) (n' * 4); ()
val slice_commutes_le_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n')) let slice_commutes_le_seq_quad32_to_bytes (s: seq quad32) (n: nat{n <= length s}) (n': nat{n <= n' /\ n' <= length s}) : Lemma (slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n')) =
false
null
true
le_seq_quad32_to_bytes_reveal (); slice_commutes_seq_four_to_seq_LE s n n'; assert (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')); slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_LE s) (n * 4) (n' * 4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) in slice_commutes_seq_four_to_seq_LE s_inner (n * 4) (n' * 4); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.l_and", "Prims.unit", "Vale.Arch.Types.slice_commutes_seq_four_to_seq_LE", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words_s.four", "Vale.Lib.Seqs_s.seq_map", "Vale.Def.Types_s.nat32", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Seq_s.seq_four_to_seq_LE", "Vale.Lib.Seqs.slice_seq_map_commute", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.slice", "Vale.Def.Types_s.le_seq_quad32_to_bytes_reveal", "Prims.l_True", "Prims.squash", "Vale.Def.Types_s.nat8", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE () let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] = seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s let lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] = seq_map_inverses reverse_bytes_quad32 reverse_bytes_quad32 s let lemma_le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (le_seq_quad32_to_bytes s) == (length s) * 16) = () let lemma_be_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == (length s) * 16) = () let slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) (seq_four_to_seq_LE (slice s n n'))); () let slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); assert (equal (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4)) (seq_four_to_seq_BE (slice s n n'))); () let slice_commutes_le_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n'))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val slice_commutes_le_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n'))
[]
Vale.Arch.Types.slice_commutes_le_seq_quad32_to_bytes
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> n: Prims.nat{n <= FStar.Seq.Base.length s} -> n': Prims.nat{n <= n' /\ n' <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.Def.Types_s.le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.slice s n n'))
{ "end_col": 4, "end_line": 650, "start_col": 2, "start_line": 636 }
FStar.Pervasives.Lemma
val slice_commutes_be_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) (n * 16) (n' * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s n n')))
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let slice_commutes_be_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) (n * 16) (n' * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s n n'))) = slice_commutes_seq_four_to_seq_BE s n n'; assert (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')); slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_BE s) (n*4) (n'*4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)) in slice_commutes_seq_four_to_seq_BE s_inner (n * 4) (n' * 4); ()
val slice_commutes_be_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) (n * 16) (n' * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s n n'))) let slice_commutes_be_seq_quad32_to_bytes (s: seq quad32) (n: nat{n <= length s}) (n': nat{n <= n' /\ n' <= length s}) : Lemma (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) (n * 16) (n' * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s n n'))) =
false
null
true
slice_commutes_seq_four_to_seq_BE s n n'; assert (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')); slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_BE s) (n * 4) (n' * 4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)) in slice_commutes_seq_four_to_seq_BE s_inner (n * 4) (n' * 4); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.l_and", "Prims.unit", "Vale.Arch.Types.slice_commutes_seq_four_to_seq_BE", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words_s.four", "Vale.Lib.Seqs_s.seq_map", "Vale.Def.Types_s.nat32", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Lib.Seqs.slice_seq_map_commute", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.slice", "Prims.l_True", "Prims.squash", "Vale.Def.Words_s.nat8", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE () let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] = seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s let lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] = seq_map_inverses reverse_bytes_quad32 reverse_bytes_quad32 s let lemma_le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (le_seq_quad32_to_bytes s) == (length s) * 16) = () let lemma_be_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == (length s) * 16) = () let slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) (seq_four_to_seq_LE (slice s n n'))); () let slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); assert (equal (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4)) (seq_four_to_seq_BE (slice s n n'))); () let slice_commutes_le_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n')) = le_seq_quad32_to_bytes_reveal (); slice_commutes_seq_four_to_seq_LE s n n'; assert (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')); (* le_seq_quad32_to_bytes (slice s n n') == seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE (slice s n n'))); == seq_four_to_seq_LE (seq_map (nat_to_four 8) (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))) (n * 16) (n' * 16) == seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) (n * 4) (n' * 4)) *) slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_LE s) (n*4) (n'*4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) in slice_commutes_seq_four_to_seq_LE s_inner (n * 4) (n' * 4); () let slice_commutes_be_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) (n * 16) (n' * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s n n')))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val slice_commutes_be_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) (n * 16) (n' * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s n n')))
[]
Vale.Arch.Types.slice_commutes_be_seq_quad32_to_bytes
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> n: Prims.nat{n <= FStar.Seq.Base.length s} -> n': Prims.nat{n <= n' /\ n' <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE s)) (n * 16) (n' * 16) == Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE (FStar.Seq.Base.slice s n n')))
{ "end_col": 4, "end_line": 662, "start_col": 2, "start_line": 656 }
FStar.Pervasives.Lemma
val slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n'))
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) (seq_four_to_seq_LE (slice s n n'))); ()
val slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')) let slice_commutes_seq_four_to_seq_LE (#a: Type) (s: seq (four a)) (n: nat{n <= length s}) (n': nat{n <= n' /\ n' <= length s}) : Lemma (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')) =
false
null
true
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) (seq_four_to_seq_LE (slice s n n'))); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.four", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.l_and", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Vale.Def.Words.Seq_s.seq_four_to_seq_LE", "FStar.Mul.op_Star", "FStar.Pervasives.reveal_opaque", "Prims.eq2", "Prims.int", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE () let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] = seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s let lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] = seq_map_inverses reverse_bytes_quad32 reverse_bytes_quad32 s let lemma_le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (le_seq_quad32_to_bytes s) == (length s) * 16) = () let lemma_be_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == (length s) * 16) = () let slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n'))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n'))
[]
Vale.Arch.Types.slice_commutes_seq_four_to_seq_LE
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq (Vale.Def.Words_s.four a) -> n: Prims.nat{n <= FStar.Seq.Base.length s} -> n': Prims.nat{n <= n' /\ n' <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s) (n * 4) (n' * 4) == Vale.Def.Words.Seq_s.seq_four_to_seq_LE (FStar.Seq.Base.slice s n n'))
{ "end_col": 4, "end_line": 621, "start_col": 2, "start_line": 618 }
FStar.Pervasives.Lemma
val be_quad32_to_bytes_injective: unit -> Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b')
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper
val be_quad32_to_bytes_injective: unit -> Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') let be_quad32_to_bytes_injective () : Lemma (forall b b'. be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') =
false
null
true
reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b': quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then (let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective (); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; ()) in FStar.Classical.forall_intro_2 helper
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Classical.forall_intro_2", "Vale.Def.Types_s.quad32", "Prims.l_imp", "Prims.eq2", "Vale.Def.Words.Seq_s.seq16", "Vale.Def.Words_s.nat8", "Vale.Arch.Types.be_quad32_to_bytes", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims.op_Equality", "Vale.Def.Words.Seq.four_to_seq_BE_injective", "Vale.Def.Words_s.nat32", "Prims._assert", "Vale.Def.Words.Seq_s.seq4", "Vale.Def.Types_s.nat32", "Vale.Def.Words.Seq_s.four_to_seq_BE", "Vale.Lib.Seqs.seq_map_injective", "Vale.Def.Words_s.four", "Vale.Def.Words_s.natN", "Prims.pow2", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words.Seq.nat_to_four_8_injective", "FStar.Seq.Base.seq", "Vale.Def.Words.Seq.seq_four_to_seq_BE_injective_specific", "Prims.l_or", "Prims.int", "FStar.Seq.Base.length", "FStar.Mul.op_Star", "Prims.nat", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Lib.Seqs_s.seq_map", "Prims.bool", "FStar.Pervasives.reveal_opaque", "Prims.l_Forall" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b')
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_quad32_to_bytes_injective: unit -> Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b')
[]
Vale.Arch.Types.be_quad32_to_bytes_injective
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (b: Vale.Def.Types_s.quad32) (b': Vale.Def.Types_s.quad32). Vale.Arch.Types.be_quad32_to_bytes b == Vale.Arch.Types.be_quad32_to_bytes b' ==> b == b')
{ "end_col": 39, "end_line": 497, "start_col": 2, "start_line": 480 }
FStar.Pervasives.Lemma
val append_distributes_le_bytes_to_seq_quad32 (s1:seq nat8 { length s1 % 16 == 0 }) (s2:seq nat8 { length s2 % 16 == 0 }) : Lemma(le_bytes_to_seq_quad32 (s1 @| s2) == (le_bytes_to_seq_quad32 s1) @| (le_bytes_to_seq_quad32 s2))
[ { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let append_distributes_le_bytes_to_seq_quad32 (s1:seq nat8 { length s1 % 16 == 0 }) (s2:seq nat8 { length s2 % 16 == 0 }) : Lemma(le_bytes_to_seq_quad32 (s1 @| s2) == (le_bytes_to_seq_quad32 s1) @| (le_bytes_to_seq_quad32 s2)) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; let s1' = seq_nat8_to_seq_nat32_LE s1 in let s2' = seq_nat8_to_seq_nat32_LE s2 in // (le_bytes_to_seq_quad32 s1) @| (le_bytes_to_seq_quad32 s2)) // = { Definition of le_bytes_to_seq_quad32 } // seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s1) @| seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s2) append_distributes_seq_to_seq_four_LE s1' s2'; // = // seq_to_seq_four_LE ((seq_nat8_to_seq_nat32_LE s1) @| (seq_nat8_to_seq_nat32_LE s2)) append_distributes_seq_map (four_to_nat 8) (seq_to_seq_four_LE s1) (seq_to_seq_four_LE s2); // seq_to_seq_four_LE (seq_map (four_to_nat 8) ((seq_to_seq_four_LE s1) @| (seq_to_seq_four_LE s2))) append_distributes_seq_to_seq_four_LE s1 s2; // seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (s1 @| s2))) // le_bytes_to_seq_quad32 (s1 @| s2) ()
val append_distributes_le_bytes_to_seq_quad32 (s1:seq nat8 { length s1 % 16 == 0 }) (s2:seq nat8 { length s2 % 16 == 0 }) : Lemma(le_bytes_to_seq_quad32 (s1 @| s2) == (le_bytes_to_seq_quad32 s1) @| (le_bytes_to_seq_quad32 s2)) let append_distributes_le_bytes_to_seq_quad32 (s1: seq nat8 {length s1 % 16 == 0}) (s2: seq nat8 {length s2 % 16 == 0}) : Lemma (le_bytes_to_seq_quad32 (s1 @| s2) == (le_bytes_to_seq_quad32 s1) @| (le_bytes_to_seq_quad32 s2) ) =
false
null
true
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; let s1' = seq_nat8_to_seq_nat32_LE s1 in let s2' = seq_nat8_to_seq_nat32_LE s2 in append_distributes_seq_to_seq_four_LE s1' s2'; append_distributes_seq_map (four_to_nat 8) (seq_to_seq_four_LE s1) (seq_to_seq_four_LE s2); append_distributes_seq_to_seq_four_LE s1 s2; ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Prims.unit", "Vale.Def.Words.Seq.append_distributes_seq_to_seq_four_LE", "Vale.Lib.Seqs.append_distributes_seq_map", "Vale.Def.Words_s.four", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Seq_s.seq_to_seq_four_LE", "Vale.Def.Words_s.nat32", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE", "FStar.Pervasives.reveal_opaque", "Vale.Def.Types_s.nat8", "Vale.Def.Types_s.quad32", "Prims.l_True", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Prims.squash", "FStar.Seq.Base.op_At_Bar", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); () let push_pop_xmm (x y:quad32) : Lemma (let x' = insert_nat64 (insert_nat64 y (hi64 x) 1) (lo64 x) 0 in x == x') = // assert (nat_to_two 32 (hi64 x) == two_select (four_to_two_two x) 1); insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_insrq_extrq_relations (x y:quad32) : Lemma (let z = insert_nat64 x (lo64 y) 0 in z == Mkfour y.lo0 y.lo1 x.hi2 x.hi3 /\ (let z = insert_nat64 x (hi64 y) 1 in z == Mkfour x.lo0 x.lo1 y.hi2 y.hi3)) = let open Vale.Def.Words.Two in let z = insert_nat64 x (lo64 y) 0 in insert_nat64_reveal (); lo64_reveal (); hi64_reveal (); assert (z == insert_nat64_def x (lo64_def y) 0); //assert (q'.hi2 == q.hi2); //assert (q'.hi3 == q.hi3); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (lo64 q)) 0)); //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (nat_to_two 32 (two_to_nat 32 (two_select (four_to_two_two q) 0))) 0)); let Mktwo n1 n2 = two_select (four_to_two_two y) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two y) 1 in nat_to_two_to_nat n1 n2; //assert (q' == two_two_to_four (two_insert (four_to_two_two q) (two_select (four_to_two_two q) 0) 0)); //assert (q'.lo1 == q.lo1); //assert (q == q'); () open Vale.Def.Words.Two let le_bytes_to_nat64_to_bytes s = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_nat64_to_bytes_to_nat64 n = le_nat64_to_bytes_reveal (); le_bytes_to_nat64_reveal () let le_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (le_bytes_to_seq_quad32 s)) } length s == 0 ==> length (le_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; () let be_bytes_to_seq_quad32_empty () : Lemma (forall s . {:pattern (length (be_bytes_to_seq_quad32 s)) } length s == 0 ==> length (be_bytes_to_seq_quad32 s) == 0) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; () #reset-options "--z3rlimit 10 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let le_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { le_bytes_to_seq_quad32 (le_quad32_to_bytes b); == {reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_quad32_to_bytes b)); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b)))); == {} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))))); == {seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE b))} seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_LE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_LE b)} seq_to_seq_four_LE (four_to_seq_LE b); == {four_to_seq_LE_is_seq_four_to_seq_LE b} seq_to_seq_four_LE (seq_four_to_seq_LE (create 1 b)); == {} create 1 b; } let be_bytes_to_seq_quad32_to_bytes_one_quad b = calc (==) { be_bytes_to_seq_quad32 (be_quad32_to_bytes b); == {reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (be_quad32_to_bytes b)); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_to_seq_four_BE (seq_nat8_to_seq_nat32_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b)))); == {} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE (seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))))); == {seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE b))} seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_map (nat_to_four 8) (four_to_seq_BE b))); == {seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE b)} seq_to_seq_four_BE (four_to_seq_BE b); == {four_to_seq_BE_is_seq_four_to_seq_BE b} seq_to_seq_four_BE (seq_four_to_seq_BE (create 1 b)); == {} create 1 b; } let le_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes s) == s) (* This expands into showing: le_bytes_to_seq_quad32 (le_quad32_to_bytes s) == { definition of le_bytes_to_seq_quad32 } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)) == { definition of le_seq_quad32_to_bytes } seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s))) == { definition of seq_nat8_to_seq_nat32_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE s)))) == { definition of seq_nat32_to_seq_nat8_LE } seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))))) *) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); seq_to_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_LE s); seq_to_seq_four_to_seq_LE (s) ; () let be_bytes_to_seq_quad32_to_bytes (s:seq quad32) : Lemma (be_bytes_to_seq_quad32 (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == s) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (seq_four_to_seq_BE s); seq_to_seq_four_to_seq_BE (s) ; () let le_seq_quad32_to_bytes_to_seq_quad32 s = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_seq_quad32_to_bytes_reveal (); calc (==) { le_seq_quad32_to_bytes (le_bytes_to_seq_quad32 s); (==) { } seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE (seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE s))); (==) { } s; } (* le_quad32_to_bytes (le_bytes_to_quad32 s) == { definition of le_quad32_to_bytes } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (le_bytes_to_quad32 s))) == { definition of le_bytes_to_quad32 } seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))) *) let le_quad32_to_bytes_to_quad32 s = calc (==) { le_quad32_to_bytes (le_bytes_to_quad32 s); == {le_bytes_to_quad32_reveal ()} le_quad32_to_bytes (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes} seq_four_to_seq_LE (seq_map (nat_to_four 8) (four_to_seq_LE (seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))))); == {four_to_seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))} seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_LE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_LE s)} seq_four_to_seq_LE (seq_to_seq_four_LE s); == {} s; } let be_quad32_to_bytes_to_quad32 s = calc (==) { be_quad32_to_bytes (be_bytes_to_quad32 s); == {be_bytes_to_quad32_reveal ()} be_quad32_to_bytes (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes} seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE (seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))))); == {four_to_seq_to_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))} seq_four_to_seq_BE (seq_map (nat_to_four 8) (seq_map (four_to_nat 8) (seq_to_seq_four_BE s))); == {seq_map_inverses (four_to_nat 8) (nat_to_four 8) (seq_to_seq_four_BE s)} seq_four_to_seq_BE (seq_to_seq_four_BE s); == {} s; } let le_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q)) = le_seq_quad32_to_bytes_reveal (); reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; four_to_seq_LE_is_seq_four_to_seq_LE q; () let be_seq_quad32_to_bytes_of_singleton (q:quad32) : Lemma (be_quad32_to_bytes q == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 q))) = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; four_to_seq_BE_is_seq_four_to_seq_BE q; () let le_quad32_to_bytes_injective (): Lemma (forall b b' . le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%le_quad32_to_bytes) le_quad32_to_bytes; let helper (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = if le_quad32_to_bytes b = le_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_LE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_LE b') in assert (le_quad32_to_bytes b == seq_four_to_seq_LE b1); assert (le_quad32_to_bytes b' == seq_four_to_seq_LE b1'); seq_four_to_seq_LE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_LE b) (four_to_seq_LE b'); assert ((four_to_seq_LE b) == (four_to_seq_LE b')); four_to_seq_LE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let be_quad32_to_bytes_injective (): Lemma (forall b b' . be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = reveal_opaque (`%be_quad32_to_bytes) be_quad32_to_bytes; let helper (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = if be_quad32_to_bytes b = be_quad32_to_bytes b' then ( let b1 = seq_map (nat_to_four 8) (four_to_seq_BE b) in let b1' = seq_map (nat_to_four 8) (four_to_seq_BE b') in assert (be_quad32_to_bytes b == seq_four_to_seq_BE b1); assert (be_quad32_to_bytes b' == seq_four_to_seq_BE b1'); seq_four_to_seq_BE_injective_specific b1 b1'; assert (b1 == b1'); nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (four_to_seq_BE b) (four_to_seq_BE b'); assert ((four_to_seq_BE b) == (four_to_seq_BE b')); four_to_seq_BE_injective nat32; () ) else () in FStar.Classical.forall_intro_2 helper let le_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (le_quad32_to_bytes b == le_quad32_to_bytes b' ==> b == b') = le_quad32_to_bytes_injective() let be_quad32_to_bytes_injective_specific (b b':quad32) : Lemma (be_quad32_to_bytes b == be_quad32_to_bytes b' ==> b == b') = be_quad32_to_bytes_injective() let le_seq_quad32_to_bytes_injective (b b':seq quad32) = le_seq_quad32_to_bytes_reveal (); seq_four_to_seq_LE_injective nat8; nat_to_four_8_injective(); seq_map_injective (nat_to_four 8) (seq_four_to_seq_LE b) (seq_four_to_seq_LE b'); seq_four_to_seq_LE_injective_specific b b'; assert (equal b b') let seq_to_four_LE_is_seq_to_seq_four_LE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_LE s) == seq_to_seq_four_LE s) = reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #a); assert (equal (create 1 (seq_to_four_LE s)) (seq_to_seq_four_LE s)); () let seq_to_four_BE_is_seq_to_seq_four_BE (#a:Type) (s:seq4 a) : Lemma (create 1 (seq_to_four_BE s) == seq_to_seq_four_BE s) = reveal_opaque (`%seq_to_seq_four_BE) (seq_to_seq_four_BE #a); assert (equal (create 1 (seq_to_four_BE s)) (seq_to_seq_four_BE s)); () let le_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == le_bytes_to_quad32 b) (ensures create 1 q == le_bytes_to_seq_quad32 b) = reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32; le_bytes_to_quad32_reveal (); seq_to_four_LE_is_seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)); // q == le_bytes_to_quad32 b // == seq_to_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // // == seq_to_seq_four_LE (seq_map (four_to_nat 8) (seq_to_seq_four_LE b)) // le_bytes_to_seq_quad32 b == seq_to_seq_four_LE (seq_nat8_to_seq_nat32_LE b) () let be_bytes_to_seq_quad_of_singleton (q:quad32) (b:seq nat8 { length b == 16 }) : Lemma (requires q == be_bytes_to_quad32 b) (ensures create 1 q == be_bytes_to_seq_quad32 b) = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; be_bytes_to_quad32_reveal (); seq_to_four_BE_is_seq_to_seq_four_BE (seq_map (four_to_nat 8) (seq_to_seq_four_BE b)); () let le_bytes_to_quad32_to_bytes (q:quad32) : Lemma(le_bytes_to_quad32 (le_quad32_to_bytes q) == q) = le_seq_quad32_to_bytes_of_singleton q; // ==> le_quad32_to_bytes q == le_seq_quad32_to_bytes (create 1 q) let b = le_quad32_to_bytes q in let q' = le_bytes_to_quad32 b in le_bytes_to_seq_quad_of_singleton q' b; // ==> create 1 q' == le_bytes_to_seq_quad32 b // == le_bytes_to_seq_quad32 (le_seq_quad32_to_bytes (create 1 q)) le_bytes_to_seq_quad32_to_bytes (create 1 q); // == create 1 q //assert (create 1 q == create 1 q'); //assert (equal (create 1 q) (create 1 q')); assert (q == index (create 1 q) 0); // OBSERVE assert (q == q'); () let be_bytes_to_quad32_to_bytes (q:quad32) : Lemma (be_bytes_to_quad32 (be_quad32_to_bytes q) == q) = be_bytes_to_quad32_reveal (); let q':quad32 = be_bytes_to_quad32 (be_quad32_to_bytes q) in seq_to_seq_four_to_seq_BE (seq_map (nat_to_four 8) (four_to_seq_BE q)); seq_map_inverses (nat_to_four 8) (four_to_nat 8) (four_to_seq_BE q); seq_to_four_to_seq_BE q; () let lemma_reverse_reverse_bytes_nat32_quad32 (s:quad32) : Lemma (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s) == s) [SMTPat (reverse_bytes_nat32_quad32 (reverse_bytes_nat32_quad32 s))] = let s' = reverse_bytes_nat32_quad32 s in let s''= reverse_bytes_nat32_quad32 s' in assert (s''.lo0 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo0)); // OBSERVE assert (s''.lo1 == reverse_bytes_nat32 (reverse_bytes_nat32 s.lo1)); // OBSERVE assert (s''.hi2 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi2)); // OBSERVE assert (s''.hi3 == reverse_bytes_nat32 (reverse_bytes_nat32 s.hi3)); // OBSERVE () let lemma_reverse_reverse_bytes_nat32_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s) == s) [SMTPat (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq s))] = seq_map_inverses reverse_bytes_nat32_quad32 reverse_bytes_nat32_quad32 s let lemma_reverse_reverse_bytes_quad32_seq (s:seq quad32) : Lemma (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s) == s) [SMTPat (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq s))] = seq_map_inverses reverse_bytes_quad32 reverse_bytes_quad32 s let lemma_le_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (le_seq_quad32_to_bytes s) == (length s) * 16) = () let lemma_be_seq_quad32_to_bytes_length (s:seq quad32) : Lemma(length (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) == (length s) * 16) = () let slice_commutes_seq_four_to_seq_LE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #a); assert (equal (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) (seq_four_to_seq_LE (slice s n n'))); () let slice_commutes_seq_four_to_seq_BE (#a:Type) (s:seq (four a)) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')) = reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #a); assert (equal (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4)) (seq_four_to_seq_BE (slice s n n'))); () let slice_commutes_le_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == le_seq_quad32_to_bytes (slice s n n')) = le_seq_quad32_to_bytes_reveal (); slice_commutes_seq_four_to_seq_LE s n n'; assert (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4) == seq_four_to_seq_LE (slice s n n')); (* le_seq_quad32_to_bytes (slice s n n') == seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE (slice s n n'))); == seq_four_to_seq_LE (seq_map (nat_to_four 8) (slice (seq_four_to_seq_LE s) (n * 4) (n' * 4)) slice (le_seq_quad32_to_bytes s) (n * 16) (n' * 16) == slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE s))) (n * 16) (n' * 16) == seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) (n * 4) (n' * 4)) *) slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_LE s) (n*4) (n'*4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_LE s)) in slice_commutes_seq_four_to_seq_LE s_inner (n * 4) (n' * 4); () let slice_commutes_be_seq_quad32_to_bytes (s:seq quad32) (n:nat{n <= length s}) (n':nat{ n <= n' /\ n' <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) (n * 16) (n' * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s n n'))) = slice_commutes_seq_four_to_seq_BE s n n'; assert (slice (seq_four_to_seq_BE s) (n * 4) (n' * 4) == seq_four_to_seq_BE (slice s n n')); slice_seq_map_commute (nat_to_four 8) (seq_four_to_seq_BE s) (n*4) (n'*4); let s_inner = (seq_map (nat_to_four 8) (seq_four_to_seq_BE s)) in slice_commutes_seq_four_to_seq_BE s_inner (n * 4) (n' * 4); () let slice_commutes_le_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (le_seq_quad32_to_bytes s) 0 (n * 16) == le_seq_quad32_to_bytes (slice s 0 n)) = slice_commutes_le_seq_quad32_to_bytes s 0 n let slice_commutes_be_seq_quad32_to_bytes0 (s:seq quad32) (n:nat{n <= length s}) : Lemma(slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE s)) 0 (n * 16) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice s 0 n))) = slice_commutes_be_seq_quad32_to_bytes s 0 n #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq.Properties'" let append_distributes_le_bytes_to_seq_quad32 (s1:seq nat8 { length s1 % 16 == 0 }) (s2:seq nat8 { length s2 % 16 == 0 }) : Lemma(le_bytes_to_seq_quad32 (s1 @| s2) == (le_bytes_to_seq_quad32 s1) @| (le_bytes_to_seq_quad32 s2))
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val append_distributes_le_bytes_to_seq_quad32 (s1:seq nat8 { length s1 % 16 == 0 }) (s2:seq nat8 { length s2 % 16 == 0 }) : Lemma(le_bytes_to_seq_quad32 (s1 @| s2) == (le_bytes_to_seq_quad32 s1) @| (le_bytes_to_seq_quad32 s2))
[]
Vale.Arch.Types.append_distributes_le_bytes_to_seq_quad32
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s1: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 {FStar.Seq.Base.length s1 % 16 == 0} -> s2: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 {FStar.Seq.Base.length s2 % 16 == 0} -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.le_bytes_to_seq_quad32 (s1 @| s2) == Vale.Def.Types_s.le_bytes_to_seq_quad32 s1 @| Vale.Def.Types_s.le_bytes_to_seq_quad32 s2)
{ "end_col": 4, "end_line": 694, "start_col": 2, "start_line": 680 }
FStar.Pervasives.Lemma
val lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) )
[ { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q; // lemma_equality_check_helper_hi q; lo64_reveal (); hi64_reveal (); assert (forall (x:two nat32).{:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); ()
val lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) let lemma_equality_check_helper (q: quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) =
false
null
true
lo64_reveal (); hi64_reveal (); assert (forall (x: two nat32). {:pattern (two_to_nat 32 x)} two_to_nat 32 x == two_to_nat_unfold 32 x); ()
{ "checked_file": "Vale.Arch.Types.fst.checked", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Arch.Types.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Prims.unit", "Prims._assert", "Prims.l_Forall", "Vale.Def.Words_s.two", "Vale.Def.Words_s.nat32", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Two_s.two_to_nat", "Vale.Def.Words.Two_s.two_to_nat_unfold", "Vale.Arch.Types.hi64_reveal", "Vale.Arch.Types.lo64_reveal", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.l_imp", "Prims.int", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Arch.Types.lo64", "Prims.l_or", "Prims.b2t", "Prims.op_Negation", "Prims.op_Equality", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Arch.Types.hi64", "Prims.l_not", "Prims.l_iff", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.Arch.Types open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.TypesNative open Vale.Lib.Seqs open Vale.Def.Words_s open Vale.Def.Words.Two open FStar.Calc let lemma_nat_to_two32 () = assert_norm (forall (x:nat64).{:pattern (nat_to_two 32 x)} nat_to_two 32 x == Mktwo (x % 0x100000000) (x / 0x100000000)) let lemma_BitwiseXorCommutative x y = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ y) (y *^ x) let lemma_BitwiseXorWithZero n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ 0) n let lemma_BitwiseXorCancel n = lemma_ixor_nth_all 32; lemma_zero_nth 32; lemma_equal_nth 32 (n *^ n) 0 let lemma_BitwiseXorCancel64 (n:nat64) = lemma_ixor_nth_all 64; lemma_zero_nth 64; lemma_equal_nth 64 (ixor n n) 0 let lemma_BitwiseXorAssociative x y z = lemma_ixor_nth_all 32; lemma_equal_nth 32 (x *^ (y *^ z)) ((x *^ y) *^ z) let xor_lemmas () = FStar.Classical.forall_intro_2 lemma_BitwiseXorCommutative; FStar.Classical.forall_intro lemma_BitwiseXorWithZero; FStar.Classical.forall_intro lemma_BitwiseXorCancel; FStar.Classical.forall_intro lemma_BitwiseXorCancel64; FStar.Classical.forall_intro_3 lemma_BitwiseXorAssociative; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_quad32_xor () = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); xor_lemmas() (* let helper (q:quad32) : Lemma (quad32_xor q q == Mkfour 0 0 0 0) = let q' = quad32_xor q q in quad32_xor_reveal (); reverse_bytes_nat32_reveal (); // REVIEW: Why are these necessary? assert (q'.lo0 == nat32_xor q.lo0 q.lo0); assert (q'.lo1 == nat32_xor q.lo1 q.lo1); assert (q'.hi2 == nat32_xor q.hi2 q.hi2); assert (q'.hi3 == nat32_xor q.hi3 q.hi3); xor_lemmas() in FStar.Classical.forall_intro helper *) #pop-options let lemma_reverse_reverse_bytes_nat32 (n:nat32) : Lemma (reverse_bytes_nat32 (reverse_bytes_nat32 n) == n) = reverse_bytes_nat32_reveal (); let r = reverse_seq (nat32_to_be_bytes n) in be_bytes_to_nat32_to_be_bytes r; () #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_reverse_bytes_quad32 (q:quad32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); reveal_reverse_bytes_quad32 q; reveal_reverse_bytes_quad32 (reverse_bytes_quad32 q); () #pop-options let lemma_reverse_bytes_nat32 (_:unit) : Lemma (reverse_bytes_nat32 0 == 0) = reverse_bytes_nat32_reveal (); assert_norm (nat_to_four 8 0 == Mkfour 0 0 0 0); () let lemma_reverse_bytes_quad32_zero (_:unit) : Lemma (let z = Mkfour 0 0 0 0 in reverse_bytes_quad32 z == z) = let z = Mkfour 0 0 0 0 in calc (==) { reverse_bytes_quad32 z; == { reveal_reverse_bytes_quad32 z } four_reverse (four_map reverse_bytes_nat32 z); == { lemma_reverse_bytes_nat32() } z; }; () let lemma_reverse_reverse_bytes_nat32_seq (s:seq nat32) : Lemma (ensures reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s) == s) = reveal_reverse_bytes_nat32_seq s; reveal_reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s); assert (equal (reverse_bytes_nat32_seq (reverse_bytes_nat32_seq s)) s) (* let lemma_equality_check_helper_two_to_nat_32 (n:two nat32) : Lemma ( ((n.lo == 0 /\ n.hi == 0) ==> two_to_nat 32 n == 0) /\ ( ~(n.lo == 0) \/ (~(n.hi == 0))) ==> ~(two_to_nat 32 n == 0) /\ ((n.lo == 0xFFFFFFFF /\ n.hi == 0xFFFFFFFF) <==> two_to_nat 32 n == 0xFFFFFFFFFFFFFFFF)) = if n.lo == 0 /\ n.hi == 0 then ( assert (int_to_natN pow2_64 (n.lo + pow2_32 * n.hi) == 0); () ) else ( () ); () let lemma_equality_check_helper_lo (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF)) = assert (lo64 q == two_to_nat 32 (Mktwo q.lo0 q.lo1)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.lo0 q.lo1); () let lemma_equality_check_helper_hi (q:quad32) : Lemma ((q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF)) = assert (hi64 q == two_to_nat 32 (Mktwo q.hi2 q.hi3)); lemma_equality_check_helper_two_to_nat_32 (Mktwo q.hi2 q.hi3); () *) let lemma_insert_nat64_properties (q:quad32) (n:nat64) : Lemma ( (let q' = insert_nat64 q n 0 in q'.hi2 == q.hi2 /\ q'.hi3 == q.hi3) /\ (let q' = insert_nat64 q n 1 in q'.lo0 == q.lo0 /\ q'.lo1 == q.lo1)) = insert_nat64_reveal (); () let lemma_insert_nat64_nat32s (q:quad32) (n0 n1:nat32) : Lemma ( insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 0 == Mkfour n0 n1 q.hi2 q.hi3 /\ insert_nat64 q (two_to_nat32 (Mktwo n0 n1)) 1 == Mkfour q.lo0 q.lo1 n0 n1 ) = let open Vale.Def.Words.Two in insert_nat64_reveal (); () let lemma_lo64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = lo64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.lo0 == q1.lo0 /\ q0.lo1 == q1.lo1) <==> (lo64 q0 == lo64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 0 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 0 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_hi64_properties (_:unit) : Lemma (forall (q0 q1:quad32) . (q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = hi64_reveal (); let helper (q0 q1:quad32) : Lemma ((q0.hi2 == q1.hi2 /\ q0.hi3 == q1.hi3) <==> (hi64 q0 == hi64 q1)) = let Mktwo n1 n2 = two_select (four_to_two_two q0) 1 in nat_to_two_to_nat n1 n2; let Mktwo n1 n2 = two_select (four_to_two_two q1) 1 in nat_to_two_to_nat n1 n2; () in FStar.Classical.forall_intro_2 helper; () let lemma_reverse_bytes_nat64_32 (n0 n1:nat32) : Lemma (reverse_bytes_nat64 (two_to_nat32 (Mktwo n0 n1)) == two_to_nat32 (Mktwo (reverse_bytes_nat32 n1) (reverse_bytes_nat32 n0))) = reverse_bytes_nat64_reveal () let lemma_reverse_bytes_quad32_64 (src orig final:quad32) : Lemma (requires final == insert_nat64 (insert_nat64 orig (reverse_bytes_nat64 (hi64 src)) 0) (reverse_bytes_nat64 (lo64 src)) 1) (ensures final == reverse_bytes_quad32 src) = reverse_bytes_nat64_reveal (); let Mkfour x0 x1 x2 x3 = src in let two32 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2))) in let two10 = (two_to_nat32 (Mktwo (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0))) in calc (==) { reverse_bytes_quad32 src; == { reveal_reverse_bytes_quad32 src } four_reverse (four_map reverse_bytes_nat32 src); == {} four_reverse (Mkfour (reverse_bytes_nat32 x0) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x3)); == {} Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0); == { lemma_insert_nat64_nat32s (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) (reverse_bytes_nat32 x1) (reverse_bytes_nat32 x0) } insert_nat64 (Mkfour (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) orig.hi2 orig.hi3) two10 1; == { lemma_insert_nat64_nat32s orig (reverse_bytes_nat32 x3) (reverse_bytes_nat32 x2) } insert_nat64 (insert_nat64 orig two32 0) two10 1; }; calc (==) { reverse_bytes_nat64 (hi64 src); == { hi64_reveal ()} reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 1)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x2 x3)); == { lemma_reverse_bytes_nat64_32 x2 x3 } two32; }; calc (==) { reverse_bytes_nat64 (lo64 src); == { lo64_reveal () } reverse_bytes_nat64 (two_to_nat 32 (two_select (four_to_two_two src) 0)); == {} reverse_bytes_nat64 (two_to_nat 32 (Mktwo x0 x1)); == { lemma_reverse_bytes_nat64_32 x0 x1 } two10; }; () let lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) ) = // lemma_equality_check_helper_lo q;
false
false
Vale.Arch.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_equality_check_helper (q:quad32) : Lemma ((q.lo0 == 0 /\ q.lo1 == 0 ==> lo64 q == 0) /\ ((not (q.lo0 = 0) \/ not (q.lo1 = 0)) ==> not (lo64 q = 0)) /\ (q.hi2 == 0 /\ q.hi3 == 0 ==> hi64 q == 0) /\ ((~(q.hi2 = 0) \/ ~(q.hi3 = 0)) ==> ~(hi64 q = 0)) /\ (q.lo0 == 0xFFFFFFFF /\ q.lo1 == 0xFFFFFFFF <==> lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (q.hi2 == 0xFFFFFFFF /\ q.hi3 == 0xFFFFFFFF <==> hi64 q == 0xFFFFFFFFFFFFFFFF) )
[]
Vale.Arch.Types.lemma_equality_check_helper
{ "file_name": "vale/code/arch/Vale.Arch.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (ensures (Mkfour?.lo0 q == 0 /\ Mkfour?.lo1 q == 0 ==> Vale.Arch.Types.lo64 q == 0) /\ (Prims.op_Negation (Mkfour?.lo0 q = 0) \/ Prims.op_Negation (Mkfour?.lo1 q = 0) ==> Prims.op_Negation (Vale.Arch.Types.lo64 q = 0)) /\ (Mkfour?.hi2 q == 0 /\ Mkfour?.hi3 q == 0 ==> Vale.Arch.Types.hi64 q == 0) /\ (~(Mkfour?.hi2 q = 0) \/ ~(Mkfour?.hi3 q = 0) ==> ~(Vale.Arch.Types.hi64 q = 0)) /\ (Mkfour?.lo0 q == 0xFFFFFFFF /\ Mkfour?.lo1 q == 0xFFFFFFFF <==> Vale.Arch.Types.lo64 q == 0xFFFFFFFFFFFFFFFF) /\ (Mkfour?.hi2 q == 0xFFFFFFFF /\ Mkfour?.hi3 q == 0xFFFFFFFF <==> Vale.Arch.Types.hi64 q == 0xFFFFFFFFFFFFFFFF))
{ "end_col": 4, "end_line": 260, "start_col": 2, "start_line": 257 }